- PHP 8.2
- PostgreSQL 17.5
- Symfony 7.2
- Doctrine ORM
resources/scripts/install.batresources/scripts/install.shhttp://localhost:8080
The Swagger documentation page should appear (redirected to /api/doc).
- Full REST API documentation is available at
http://localhost:8080/api/docwith all endpoints - The documentation contains complete call and response examples, as well as error responses with examples
- (before executing commands bellow go into the app container with
docker exec -it rest_api bash) - Static code analysis is performed by PHPStan
vendor/bin/phpstan analyse - Code quality is checked according to PSR-12 and other rules using CodeSniffer
vendor/bin/phpcsor automatic fixvendor/bin/php-cs-fixer fix - Unit tests are solved using PHPUnit
php bin/phpunit - The results are available here: https://github.com/BigOHenry/rest-api-example/actions
- The registration endpoint is primarily used to create the first admin user in the system. After that, additional admins must be created by existing administrators using the /api/users endpoint.
- Users with roles ROLE_READER and ROLE_AUTHOR can be created without any limitations
- The user's email must be unique.
- The password must be at least 8 characters long, contain upper and lower case letters, a number and a special character.
{
"email": "admin@example.com",
"password": "Password1234.",
"name": "System Administrator",
"role": "ROLE_ADMIN"
}{
"message": "User created successfully",
"user": {
"id": 1
}
}- After successfully authenticate the user, a JWT/Bearer token is returned in the response, which is then used in the request header during further communication
Authorization: Bearer <token>
{
"email": "admin@example.com",
"password": "Password1234."
}{
"token": "Here is JWT token"
}- To use this endpoint (and all the others), it is first necessary to authenticate
/api/auth/login - Article name must be unique and longer than 2 characters.
- Content article must be at least 50 characters.
{
"name": "What is Lorem Ipsum?",
"content": "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
}{
"message": "Article created successfully",
"article": {
"id": 1
}
}