2017-12-05 16 views
1

私はSymfony(3.4)から始まり、ロードフィクスチャに問題があります。
私はphp bin/console doctrine:fixtures:loadを実行すると、私はメッセージを取得:Symfony Doctrineはロードするフィクスチャを見つけることができません

〜/ srcに/ AppBundle/DataFixtures/ORM/LoadUserData.php

namespace AppBundle\DataFixtures\ORM; 

use Doctrine\Common\DataFixtures\FixtureInterface; 
use Doctrine\Common\Persistence\ObjectManager; 
use Symfony\Component\DependencyInjection\ContainerAwareInterface; 
use Symfony\Component\DependencyInjection\ContainerInterface; 

class LoadUserData implements FixtureInterface, ContainerAwareInterface { 

    private $container; 

    /** 
    * Load data fixtures with the passed EntityManager 
    * 
    * @param ObjectManager $manager 
    */ 
    public function load(ObjectManager $manager) 
    { 
     $user = new User(); 
     $user->setLogin('admin'); 
     $user->setEmail('[email protected]'); 
     $encoder = $this->container->get('security.password_encoder'); 
     $password = $encoder->encodePassword($user, '123qwe'); 
     $user->setPassword($password); 

     $manager->persist(); 
     $manager->flush(); 
    } 

    public function setContainer(ContainerInterface $container = null) 
    { 
     $this->container = $container; 
    } 
} 

〜/アプリ:

 
In LoadDataFixturesDoctrineCommand.php line 95: 
    Could not find any fixture services to load. 

を私のコードがあります/config/services.yml

parameters: 

    services: 
     _defaults: 
      autowire: true 
      autoconfigure: true 
      public: false 

     AppBundle\: 
      resource: '../../src/AppBundle/*' 
      exclude: '../../src/AppBundle/{Entity,Repository,Tests}' 

     AppBundle\Controller\: 
      resource: '../../src/AppBundle/Controller' 
      public: true 
      tags: ['controller.service_arguments'] 

ありがとう。

答えて

4

使用する照明器具のバージョンによって、異なるクラスを拡張/実装する必要があります。 バージョンがある場合は> = 3.0、その後

extend Fixture (use Doctrine\Bundle\FixturesBundle\Fixture;) 

< 3.0

implements FixtureInterface, ContainerAwareInterface 
の場合
関連する問題