This repository provides a step-by-step guide to set up an API platform using Symfony. It includes the installation of required packages, creation of entities, and execution of migrations.
-
Install a new Symfony project:
symfony new ApiPlateform
-
Navigate to the project directory:
cd ApiPlateform
-
Install the API platform:
symfony composer req api
-
Install ORM, Migration, Maker, Fixtures, and Testing:
symfony composer req orm symfony composer req migrations symfony composer req --dev make symfony composer req --dev orm-fixtures symfony composer req --dev test
-
Install JWT (Json Web Token) authentication:
symfony composer req lexik/jwt-authentication-bundle
-
Install Faker (generates fake data for testing):
-
Please follow the installation instructions provided by Faker to install the package.
-
Run the following command to install the package:
composer require --dev fzaninotto/faker
-
-
Create the User entity:
bin/console make:user
-
Create the Article entity:
bin/console make:entity Article
-
Generate a migration:
symfony console make:migration
-
Execute the migration to update the database schema:
bin/console doctrine:migrations:migrate
php bin/console doctrine:fixtures:load
symfony server:start
go to =>http://127.0.0.1:8000/api
bin/phpunit
bin/console cache:clear
normalizationContext:['groups'=>['user:read']]=> indicating that only properties annotated with this group should be included in the normalized output(get/getcollection) ex: #[Groups(['user:write'])] {"email": "ypouros@hotmail.com", }
denormalizationContext:['groups'=>['user:write']]=>when deserializing input data. (post/put/patch) #[Groups(['user:write'])] { "email": "string" }