2017-07-09 6 views
0

にFixtureを見つけることができませんでした。私自身のプロジェクトをSymfony 3.3。*で実行し、DoctrineFixturesBundleをインストールしようとしました。Symfony + DoctrineFixturesはディレクトリ

これは私のフィクスチャローダーです。

namespace AdminBundle\DataFixtures\ORM; 

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

/** 
* Loading groups before running system from DoctrineFixtures. 
* 
* @author oadamczyk 
*/ 
class LoadGroupsData implements FixtureInterface, ContainerAwareInterface 
{ 

    /** 
    * 
    * @var ContainerInterface 
    */ 
    private $container; 

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

    public function load(ObjectManager $manager) 
    { 
     foreach (explode('|', $this->container->getParameter('env(ROLES_PIPE_SEPERATED)')) as $role) { 
      /** @var Group */ 
      $group = new Group(ucfirst(str_replace('ADMIN_', '', $role)), $role); 
      $manager->persist($group); 
     } 
     $manager->flush(); 
    } 

} 

これは私のAppKernelです:

use Symfony\Component\HttpKernel\Kernel; 
use Symfony\Component\Config\Loader\LoaderInterface; 

class AppKernel extends Kernel 
{ 

    public function registerBundles() 
    { 
     $bundles = [ 
      new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), 
      new Symfony\Bundle\SecurityBundle\SecurityBundle(), 
      new Symfony\Bundle\TwigBundle\TwigBundle(), 
      new Symfony\Bundle\MonologBundle\MonologBundle(), 
      new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), 
      new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), 
      new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), 
      new Sonata\CoreBundle\SonataCoreBundle(), 
      new Sonata\BlockBundle\SonataBlockBundle(), 
      new Knp\Bundle\MenuBundle\KnpMenuBundle(), 
      new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(), 
      new Sonata\AdminBundle\SonataAdminBundle(), 
      new FOS\UserBundle\FOSUserBundle(), 
//   new AppBundle\AppBundle(), 
      new AdminBundle\AdminBundle(), 
      new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle() 
     ]; 

     if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { 
      $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); 
      $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 
      $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); 

      if ('dev' === $this->getEnvironment()) { 
       $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); 
       $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle(); 
      } 
     } 

     return $bundles; 
    } 

    public function getRootDir() 
    { 
     return __DIR__; 
    } 

    public function getCacheDir() 
    { 
     return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment(); 
    } 

    public function getLogDir() 
    { 
     return dirname(__DIR__) . '/var/logs'; 
    } 

    public function registerContainerConfiguration(LoaderInterface $loader) 
    { 
     $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml'); 
    } 

} 

これは例外であることphp bin/console doctrine:fixtures:loadログ:

慎重に、データベースが削除されます。続行しますか(Y/N)?yの

[InvalidArgumentException]             
Could not find any fixtures to load in:          
    - /var/www/html/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/D 
    ataFixtures/ORM                
    - /var/www/html/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Da 
    taFixtures/ORM                
    - /var/www/html/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/DataFi 
    xtures/ORM                 
    - /var/www/html/vendor/symfony/monolog-bundle/DataFixtures/ORM    
    - /var/www/html/vendor/symfony/swiftmailer-bundle/DataFixtures/ORM   
    - /var/www/html/vendor/doctrine/doctrine-bundle/DataFixtures/ORM    
    - /var/www/html/vendor/sensio/framework-extra-bundle/DataFixtures/ORM   
    - /var/www/html/vendor/sonata-project/core-bundle/DataFixtures/ORM   
    - /var/www/html/vendor/sonata-project/block-bundle/DataFixtures/ORM   
    - /var/www/html/vendor/knplabs/knp-menu-bundle/DataFixtures/ORM    
    - /var/www/html/vendor/sonata-project/doctrine-orm-admin-bundle/DataFixture 
    s/ORM                   
    - /var/www/html/vendor/sonata-project/admin-bundle/DataFixtures/ORM   
    - /var/www/html/vendor/friendsofsymfony/user-bundle/DataFixtures/ORM   
    - /var/www/html/src/AdminBundle/DataFixtures/ORM        
    - /var/www/html/vendor/doctrine/doctrine-fixtures-bundle/DataFixtures/ORM  
    - /var/www/html/vendor/symfony/symfony/src/Symfony/Bundle/DebugBundle/DataF 
    ixtures/ORM                 
    - /var/www/html/vendor/symfony/symfony/src/Symfony/Bundle/WebProfilerBundle 
    /DataFixtures/ORM                
    - /var/www/html/vendor/sensio/distribution-bundle/DataFixtures/ORM   
    - /var/www/html/vendor/sensio/generator-bundle/DataFixtures/ORM    
    - /var/www/html/vendor/symfony/symfony/src/Symfony/Bundle/WebServerBundle/D 
    ataFixtures/ORM                


doctrine:fixtures:load [--fixtures [FIXTURES]] [--append] [--em EM] [--shard SHARD] [--purge-with-truncate] [--multiple-transactions] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> 

私はSonataAdminBundleを使用していますが、私は非常にあなたはまだそれがここで答えを探している場合、これが理由

答えて

0

こんにちはであることを疑います、私は著者がバージョン3以上の実装を変更したことを知りました。私も同じ問題に直面していました。

<?php 
namespace AdminBundle\DataFixtures\ORM; 

use Doctrine\Bundle\FixturesBundle\Fixture; 
use Doctrine\Common\Persistence\ObjectManager; 
use Symfony\Component\DependencyInjection\ContainerInterface; 
use AdminBundle\Entity\Group; 

/** 
* Loading groups before running system from DoctrineFixtures. 
* 
* @author oadamczyk 
*/ 
class LoadGroupsData extends Fixture 
{ 

    /** 
    * 
    * @var ContainerInterface 
    */ 
    private $container; 

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

    public function load(ObjectManager $manager) 
    { 
     foreach (explode('|', $this->container->getParameter('env(ROLES_PIPE_SEPERATED)')) as $role) { 
      /** @var Group */ 
      $group = new Group(ucfirst(str_replace('ADMIN_', '', $role)), $role); 
      $manager->persist($group); 
     } 
     $manager->flush(); 
    } 

} 
関連する問題