I am trying to create fixtures for my Symfony project. Unfortunately I'm plagued with the following error:
In LoadDataFixturesDoctrineCommand.php line 95:
Could not find any fixture services to load.
I have tried everything people suggested here. But no help.
My code is this:
<?php
namespace App\DataFixtures;
use App\Entity\Users;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class UserFixtures extends Fixture
{
private $encoder;
private function __construct(UserPasswordEncoderInterface $encoder){
$this->encoder = $encoder;
}
public function load(ObjectManager $manager)
{
$user = new Users();
$user->setUsername('wessel');
$user->setPassword(
$this->encoder->encodePassword($user, '123abc')
);
$user->setEmail('[email protected]');
$manager->persist($user);
$manager->flush();
}
}
I have triend editing the services.yaml aswell, i added:
App\DataFixtures\:
resource: '../src/DataFixtures'
tags: [doctrine.fixture.orm]
Unfortunately no help, what am i doing wrong?