A PHP application based on Symfony and with GraphQL endpoints.
📣 All commands have to be run in the api
service (make api
).
composer pest
This command will execute all tests and display the result and the code coverage in your terminal.
An HTML output is also available under the coverage
folder.
Do not hesitate to take a look at it!
You can also run tests per group, for instance:
pest --group=user,company
Before pushing your commits to the repository or even while coding, run the following commands:
composer csfix &&
composer cscheck &&
composer phpstan &&
composer deptrac &&
composer yaml-lint
When installing a PHP dependency, ask yourself if it is a dev
dependency or not:
composer require [--dev] [package]
COMPOSER_MEMORY_LIMIT=-1 composer normalize
As we're using Symfony, make sure to choose the package with Symfony support (aka bundle) if available.
📣 Vagrant users might encounter some issues with Composer.
A workaround solution is to add the flag --prefer-source
to your Composer command.
php bin/console doctrine:migrations:generate
This command will generate a new empty migration in the src/api/migrations folder.
Add a meaningful description:
public function getDescription() : string
{
return 'Create X, Y and Z tables.';
}
And throw the following exception in the down
method:
public function down(Schema $schema) : void
{
throw new RuntimeException('Never rollback a migration!');
}
You may now update the up
method.
php bin/console doctrine:migrations:migrate -n
This command will apply the new migrations to the database.
If you've edited an existing migration, you'll have to reset the database first:
php bin/console doctrine:database:drop -n --force &&
php bin/console doctrine:database:create -n &&
php bin/console doctrine:migrations:migrate -n
📣 You should only do that if a remote environment like your production did not already apply the migration.
php bin/console tdbm:generate
This command will regenerate the TDBM Models
and DAOs
.
The DevFixturesCommand.php class provides a Symfony command for initializing your development database with dummy data:
php bin/console app:fixtures:dev
It uses the class AppFixtures.php for that task.
You should edit according to your needs.