2017-12-05 2 views
1

Symfony (3.4)부터 시작하여로드 고정물에 문제가 있습니다. 내가 php bin/console doctrine:fixtures:load을 실행하면
그럼 내가받을 메시지 :Symfony Doctrine이로드 할 Fixture를 찾을 수 없습니다.

~/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 
경우
관련 문제