diff --git a/app/AppKernel.php b/app/AppKernel.php index e4bc9a1..24f5a5f 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -25,6 +25,8 @@ public function registerBundles() $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); + + $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); } return $bundles; diff --git a/composer.json b/composer.json index eac198c..2adc632 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,9 @@ }, "require-dev": { "sensio/generator-bundle": "^3.0", - "symfony/phpunit-bridge": "^3.0" + "symfony/phpunit-bridge": "^3.0", + + "doctrine/doctrine-fixtures-bundle": "^2.3" }, "scripts": { "post-install-cmd": [ diff --git a/composer.lock b/composer.lock index 71753b1..cd426e0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "4499f3bf68a1ed1c98a9b90bc1314ce3", - "content-hash": "c4c5dc90bd90bcb26b7a28de7620580b", + "hash": "746511d9af5e621b4931c2e538aa3406", + "content-hash": "e9fdbc27cd7b7adfae6274b6f9b2f512", "packages": [ { "name": "doctrine/annotations", @@ -2296,6 +2296,122 @@ } ], "packages-dev": [ + { + "name": "doctrine/data-fixtures", + "version": "v1.2.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/data-fixtures.git", + "reference": "b3cae5efef97191a08d53d733260f7eb667c16e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/data-fixtures/zipball/b3cae5efef97191a08d53d733260f7eb667c16e4", + "reference": "b3cae5efef97191a08d53d733260f7eb667c16e4", + "shasum": "" + }, + "require": { + "doctrine/common": "~2.2", + "php": "^5.6 || ^7.0" + }, + "conflict": { + "doctrine/orm": "< 2.4" + }, + "require-dev": { + "doctrine/dbal": "^2.5.4", + "doctrine/orm": "^2.5.4", + "phpunit/phpunit": "^5.4.6" + }, + "suggest": { + "doctrine/mongodb-odm": "For loading MongoDB ODM fixtures", + "doctrine/orm": "For loading ORM fixtures", + "doctrine/phpcr-odm": "For loading PHPCR ODM fixtures" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\DataFixtures": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Data Fixtures for all Doctrine Object Managers", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database" + ], + "time": "2016-06-20 18:08:26" + }, + { + "name": "doctrine/doctrine-fixtures-bundle", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/DoctrineFixturesBundle.git", + "reference": "0f1a2f91b349e10f5c343f75ab71d23aace5b029" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/0f1a2f91b349e10f5c343f75ab71d23aace5b029", + "reference": "0f1a2f91b349e10f5c343f75ab71d23aace5b029", + "shasum": "" + }, + "require": { + "doctrine/data-fixtures": "~1.0", + "doctrine/doctrine-bundle": "~1.0", + "php": ">=5.3.2", + "symfony/doctrine-bridge": "~2.3|~3.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Bundle\\FixturesBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Doctrine Project", + "homepage": "http://www.doctrine-project.org" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony DoctrineFixturesBundle", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "Fixture", + "persistence" + ], + "time": "2015-11-04 21:23:23" + }, { "name": "sensio/generator-bundle", "version": "v3.0.6", diff --git a/src/AppBundle/DataFixtures/ORM/LoadPostData.php b/src/AppBundle/DataFixtures/ORM/LoadPostData.php new file mode 100644 index 0000000..e3a4112 --- /dev/null +++ b/src/AppBundle/DataFixtures/ORM/LoadPostData.php @@ -0,0 +1,29 @@ +setSlug(sprintf('post-%d', $i)); + $post->setHeading(sprintf('Post %d', $i)); + $post->setContent(<<persist($post); + } + + $manager->flush(); + } +}