Skip to content

📚 🐘This web application was created for me to learn about how to work with REST APIs using Symfony.

Notifications You must be signed in to change notification settings

KrivanRaulAdrian/manage-students-api

Repository files navigation

Continuous Integration

Manage Students API

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.

Requirments

Install

  1. Clone the repository:
git clone [email protected]:KrivanRaulAdrian/manage-students-api.git
  1. Access the directory:
cd manage-students-api/
  1. Install the Composer dependencies:
composer install
  1. Go to MySQL and create the database manage-students-api
  2. Create a file .env.local and add your database connection. Example:
DATABASE_URL="mysql://root:@localhost:3306/manage-students-api"
  1. Create the tables:
php bin/console doctrine:migrations:migrate
  1. Run the application:
symfony server:start
# or
php -S localhost:8000 -t public
  1. 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*

Routes

To access the API documentation, go to http://localhost:8000/api/doc.

Quality Tools

You can run PHP CS Fixer to check the code style and PHPStan for static analysis.

Code Style

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/

Static Analysis

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

Unit Tests

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.


Learn More

To know more about the development of Symfony applications, check the official documentation.

About

📚 🐘This web application was created for me to learn about how to work with REST APIs using Symfony.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published