A basic and lean recipe for loading the database with data in Symfony3.
This application will connect to the local mysql server, create a new database
called symfony
and a new table inside this called
product
.
git
php v5.5.9+
composer
MySQL
$ mkdir -vp php-symfony-populate-database
$ cd php-symfony-populate-database
$ git clone https://github.com/benjaminvickers/php-symfony-populate-data.git .
$ composer install
Enter the database connection details when prompted by composer. Otherwise you
can edit the details in the app/config/parameters.yml
file. Remember the database name should be set to symfony
.
$ sudo service mysql start
$ php bin/console doctrine:database:create
$ php app/console doctrine:fixtures:load
$ mysql -uroot -p
$ use symfony;
$ select * from product;
http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html