composer create-project symfony/skeleton:^4.4 rest_api_project
composer require symfony/maker-bundle --dev
composer require api
Now when you create an entity with bin/console make:entity
you will be asked if you would like make the class as an API resource
Create database and update connection string in .env file
DATABASE_URL=mysql://test-api-user:[email protected]:3306/test-api?serverVersion=5.7
-
Your API is almost ready:
- Create your first API resource in src/Entity;
- Go to /api to browse your API
-
To enable the GraphQL support, run composer require webonyx/graphql-php, then browse /api/graphql.
bin/console make:user
bin/console make:entity
class name: User
@ORM\Column(type="string", length=255, unique=true)
bin/console make:migration
bin/console doctrine:migrations:migrate
symfony serve
bin/console debug:config api_platform
bin/console config:dump api_platform
bin/console cache:clear
bin/console doctrine:migrations:migrate
or if that doesn't work because of a "table already exists" error:
bin/console doctrine:schema:update --force
doctrine:schema:drop --full-database --force
composer require test --dev
<server name="SYMFONY_PHPUNIT_VERSION" value="8.2" />
composer require symfony/http-client
DATABASE_URL=mysql://symfony-demo-user:[email protected]:3306/symfony-demo-test
bin/console doctrine:database:create --env=test bin/console doctrine:schema:create --env=test
- unnecessary if using API Platform >= v2.5
instructions: https://symfonycasts.com/screencast/api-platform-security/backport-api-tests
bin/phpunit
composer require alice --dev
- This installs handy
ReloadDatabaseTrait
composer require logger
- log will be available in var/log/test.log
./bin/console security:encode-password