This POC is just a Symfony minimalist app with Doctrine and MySQL. It uses a Docker container for MySQL Database.
- PHP 8.2.0 or higher;
- PDO-SQLite PHP extension enabled;
- and the usual Symfony application requirements.
- Download Symfony CLI
- Docker Desktop
Clone this repository:
https://github.com/abdounikarim/poc-symfony-doctrine-mysql
Go on the project root folder:
cd poc-symfony-doctrine-mysql/
Install PHP dependencies:
composer install
Run docker container for MySQL:
docker-compose up -d
Create database:
symfony console doctrine:database:create
Run database migrations:
symfony console doctrine:migrations:migrate --no-interaction
Insert data with symfony command:
symfony console doctrine:query:sql "INSERT INTO dummy (name) VALUES ('Foo'), ('Bar'), ('Baz');"
Select data with symfony command:
symfony console doctrine:query:sql "SELECT * FROM dummy;"
Start the web server:
symfony serve
Then access the application in your browser at the given URL (https://localhost:8000 by default).
Create database in test env:
symfony console doctrine:database:create --env=test
Run database migrations in test env:
symfony console doctrine:migrations:migrate --no-interaction --env=test
Insert data with symfony command in test env:
symfony console doctrine:query:sql "INSERT INTO dummy (name) VALUES ('Foo'), ('Bar'), ('Baz');" --env=test
Select data with symfony command in test env:
symfony console doctrine:query:sql "SELECT * FROM dummy;" --env=test
Execute this command to run tests:
symfony run bin/phpunit