This API allows you to manage students by providing endpoints to perform CRUD operations on a list of students. Each student is defined by a registration number, name, grade, and classroom.
This API requires authentication for user management and student management endpoints. The client must sign up and log in to obtain a token to access the protected routes.
- PHP 8.2
- Composer
- MAMP
- Symfony CLI (optional)
- Clone the repository:
git clone [email protected]:KrivanRaulAdrian/manage-students-api.git
- Access the directory:
cd manage-students-api/
- Install the Composer dependencies:
composer install
- Go to MySQL and create the database
manage-students-api
- Create a file
.env.local
and add your database connection. Example:
DATABASE_URL="mysql://root:@localhost:3306/manage-students-api"
- Create the tables:
php bin/console doctrine:migrations:migrate
- Run the application:
symfony server:start
# or
php -S localhost:8000 -t public
- Go to http://localhost:8000
*Note: To generate the JWT security [keypair], use a Linux container running the following command: docker-compose run -it php-fpm php bin/console lexik:jwt:generate-keypair
*
To access the API documentation, go to http://localhost:8000/api/doc.
You can run PHP CS Fixer to check the code style and PHPStan for static analysis.
Install PHP CodeSniffer:
composer require squizlabs/php_codesniffer
Run PHP CodeSniffer:
./vendor/bin/phpcs --standard=PSR12 src/
Run PHP CodeSniffer Fixer:
./vendor/bin/phpcbf --standard=PSR12 src/
Install PHPStan:
composer require --dev phpstan/phpstan-symfony
If you also install phpstan/extension-installer then you're all set!
Manual installation
If you don't want to use phpstan/extension-installer
, include extension.neon in your project's PHPStan config:
includes:
- vendor/phpstan/phpstan-symfony/extension.neon
To perform framework-specific checks, include also this file:
includes:
- vendor/phpstan/phpstan-symfony/rules.neon
Run PHPStan:
php vendor/bin/phpstan analyze
Install PHPUnit
composer require --dev symfony/test-pack
Run Unit Tests
php bin/phpunit
This command automatically runs your application tests. Each test is a PHP class ending with "Test" (e.g. BlogControllerTest
) that lives in the tests/
directory of your application.
To know more about the development of Symfony applications, check the official documentation.