Skip to content

Latest commit

 

History

History
114 lines (77 loc) · 2.02 KB

README.md

File metadata and controls

114 lines (77 loc) · 2.02 KB

Symfony with Doctrine and MySQL

This POC is just a Symfony minimalist app with Doctrine and MySQL. It uses a Docker container for MySQL Database.

Requirements

Installation

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;"

Usage

Start the web server:

symfony serve

Then access the application in your browser at the given URL (https://localhost:8000 by default).

Tests

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