I starting with Symfony (3.4) and I have problem with load fixture.
When I execute php bin/console doctrine:fixtures:load
then I get message:
In Load
Depending on what version of fixtures you use you should extend/implement different classes. If the version is >= 3.0 then
extend Fixture (use Doctrine\Bundle\FixturesBundle\Fixture;)
If < 3.0
implements FixtureInterface, ContainerAwareInterface
In LoadDataFixturesDoctrineCommand.php
line 95:
Could not find any fixture services to load.
A Resolution: for symfony 3.4.* and doctrine-fixtures-bundle 3.0 ~/src/YC/PlatformBundle/DataFixtures/LoadCategory.php
namespace YC\PlatformBundle\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use YC\PlatformBundle\Entity\Categorie;
class LoadCategory extends Fixture
{
public function load(ObjectManager $manager)
{
$names = array(
'Développement web',
'Développement mobile',
'Graphisme',
'Integration',
'Reseau'
);
foreach ($names as $name) {
$category = new Categorie();
$category->setName($name);
$manager->persist($category);
}
$manager->flush();
}
}
~/src/YC/PlatformBundle/DataFixtures/LoadCategory.php
YC\PlatformBundle\DataFixtures:
resource: '%kernel.project_dir%/src/YC/PlatformBundle/DataFixtures'
tags: ['doctrine.fixture.orm']