This project will allow you to demonstrate your skills and proficiency with PHP and the Symfony framework. You're welcome to make it as simple or as advanced as you would like, but the most important factor is ensuring all of the tasks are completed. We recommend spending less than 90 minutes on it as well. Publish your code as a public repository on GitHub.
You will be creating a basic HTTP REST API using Symfony 7 and PHP 8. The API does not need to use any kind of authentication, and will be comprised of four endpoints. To keep this project as simple as possible, we recommend using SQLite3 as a database. The API will use JSON as the format for sending and receiving data. Errors should be handled with JSON as the response as well.
Your Symfony application needs to respond to four endpoints:
GET /
GET /customers
POST /customers
GET /customers/{customerId}
This endpoint will return the version of the API and the name of the server it is currently running on. You're free to make up any version number or scheme you wish.
{
"version": "0.0.1",
"server": "localhost"
}
This endpoint will return all customers in the database sorted by the date they were created in ascending order. A customer should have the following properties:
id
: integer, primary key, auto increment, not nullcreatedAt
: datetimetz, not nullupdatedAt
: datetimetz, not nullname
: text, not nullbirthdate
: date, nullemailAddress
: text, nullnotes
: text, null
[
{
"id": 1,
"createdAt": "2024-05-24T17:20:06+00:00",
"updatedAt": "2024-05-24T17:20:06+00:00",
"name": "John Smith",
"birthdate": "1988-04-15",
"emailAddress": "[email protected]",
"notes": "Loves vanilla ice cream."
},
{
"id": 2,
"createdAt": "2024-05-24T18:22:08+00:00",
"updatedAt": "2024-05-24T18:22:08+00:00",
"name": "Mary Jones",
"birthdate": "1962-08-25",
"emailAddress": "[email protected]",
"notes": "Has three grandchildren."
}
]
This endpoint will create a new customer record in the database and return that newly created customer. The following validation rules should be applied and an error should be returned if any of them fail:
name
: Not Blank, Greater Than 2 Characters, Less Than 129 Charactersbirthdate
: Nullable, Valid DateemailAddress
: Nullable, Valid Email Address, Less Than 129 Charactersnotes
: Nullable, Less Than 1025 Characters
{
"name": "Joe Abbott",
"birthdate": "1980-01-02",
"emailAddress": "[email protected]",
"notes": null
}
{
"id": 3,
"createdAt": "2024-05-24T19:11:08+00:00",
"updatedAt": "2024-05-24T19:11:08+00:00",
"name": "Joe Abbott",
"birthdate": "1980-01-02",
"emailAddress": "[email protected]",
"notes": null
}
This endpoint will return a specific customer identified by the {customerId}
parameter, or an error if the customer does not exist.
{
"id": 1,
"createdAt": "2024-05-24T17:20:06+00:00",
"updatedAt": "2024-05-24T17:20:06+00:00",
"name": "John Smith",
"birthdate": "1988-04-15",
"emailAddress": "[email protected]",
"notes": "Loves vanilla ice cream."
}