Bonjour,
Voila je rencontre un petit problème avec mon code.
Je faisais la formation Udemy sur les API Rest sur Symfony 4 : https://www.udemy.com/course/api-rest-avec-symfony-4-et-api-platform/learn/lecture/14976176#questions
J'en étais à l'étape des Fixtures.
Dans mon fichier AppFixtures, j'ai suivi la vidéo et ai donc un fichier comme suit:
<?php
namespace App\DataFixtures;
use App\Entity\Adherent;
use App\Entity\Livre;
use App\Entity\Pret;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Faker\Factory;
class AppFixtures extends Fixture
{
private $manager;
private $faker;
private $repoLivre;
public function __construct()
{
$this->faker=Factory::create("fr_FR");
}
public function load(ObjectManager $manager)
{
$this->manager=$manager;
$this->repoLivre=$this->manager->getRepository(Livre::class);
$this->loadAdherent();
$this->loadPret();
}
/**
* Création des adhérents
*/
public function loadAdherent(){
(...supprimé pour lecture)
}
$this->manager->flush();
}
public function loadPret(){
(...supprimé pour lecture)
}
$this->manager->persist($pret);
}
$this->manager->flush();
}
}
J'aimerais déclencher les chargements des fixtures via mon CLI
php bin/console doctrine:fixtures:load --append
J'ai 1 message d'erreur à l'execution:
In FileLoader.php line 180:
Expected to find class "App\DataFixtures\AppFixtures" in file "C:\wamp64\www\biblioApi\src/DataFixtures\AppFixtures.php" while importing services from resource "../src/*", but it was not found! Check the namespace prefix used
with the resource in C:\wamp64\www\biblioApi\config/services.yaml (which is loaded in resource "C:\wamp64\www\biblioApi\config/services.yaml").
In FileLoader.php line 208:
Expected to find class "App\DataFixtures\AppFixtures" in file "C:\wamp64\www\biblioApi\src/DataFixtures\AppFixtures.php" while importing services from resource "../src/*", but it was not found! Check the namespace prefix used
with the resource.
Dans mon fichier "service.yaml", j'ai :
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
Je ne vois pas s'il manque quelque chose dans un des fichiers. Etant un peu noob, je ne vois pas mon erreur.
D'avance merci :)