更新到Symfony 2.1.8之后,教条装置不起作用 [英] Doctrine fixtures not working after updating to Symfony 2.1.8

查看:170
本文介绍了更新到Symfony 2.1.8之后,教条装置不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将项目从Symfony 2.0.22更新到2.1.8后,执行 doctrine:fixtures:load 通过终端


致命错误:在{symfony_install_folder} / vendor / symfony / symfony / src / Symfony / Bridge / Doctrine中找不到类'Doctrine\Common\DataFixtures\Loader' /DataFixtures/ContainerAwareLoader.php在第27行


夹具工作在2.0.22,我检查了官方文档,看看我是否正确设置了所有内容



我的 composer.json 如下所示:

  {
name:symfony / framework-standard-edition,
description:The \Symfony Standard Edition \distribution,
autoload:{
psr-0:{:src /}
},
require:{
php:> = 5 .3.3,
symfony / symfony:2.1.8,
doctrine / orm:> = 2.2.3,< 2.5-dev,
doctrine / dbal:2.3.*@dev,
doctrine / doctrine-bundle:1.1。*,
twig / extensions:1.0.*@dev,
symfony / assetic-bundle:2.1。*,
symfony / swiftmailer-bundle:2.1。*,
symfony / monolog-bundle *,
sensio / distribution-bundle:2.1。*,
sensio / framework-extra-bundle:2.1。*,
sensio /捆绑:2.1。*,
jms / security-extra-bundle:1.2。*,
jms / di-extra-bundle:1.1。* b $ bkriswallsmith / assetic:1.1.*@dev,
doctrine / common:2.4.*@dev,
doctrine / data-fixtures:2.0。 * @ dev,
doctrine / doctrine-fixtures-bundle:dev-master,
gedmo / doctrine-extensions:2.3.*@dev,
stof / doctrine-extensions-bundle:1.1.*@dev,
friendsofsymfon y / jsrouting-bundle:1.1.*@dev

},
脚本:{
post-install-cmd:[
Sensio\\\Bundle\\\DistributionBundle\\Composer\\ScriptHandler :: buildBootstrap,
Sensio\\\Bundle\\\DistributionBundle\\Composer\ \ScriptHandler :: clearCache,
Sensio\\\Bundle\\\DistributionBundle\\Composer\\ScriptHandler :: installAssets,
Sensio\\\Bundle \\DistributionBundle\\Composer\\ScriptHandler :: installRequirementsFile
],
post-update-cmd:[
Sensio \\Bundle\\ \\\DistributionBundle\\Composer\\ScriptHandler :: buildBootstrap,
Sensio\\\Bundle\\\DistributionBundle\\Composer\\ScriptHandler :: clearCache,
Sensio \\ \\\Bundle\\\DistributionBundle\\Composer\\ScriptHandler :: installAssets,
Sensio\\\Bundle\\\DistributionBundle\\Composer\\\\ScriptHandler :: installRequirementsFile

},
extra:{
symfony-app-dir:app,
symfony-web-dir :web,
branch-alias:{
dev-master:2.1-dev
}
}
}

而我的应用/ AppKernel.php

 <?php 

使用Symfony\Component\HttpKernel\Kernel;
使用Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel扩展内核
{
public function registerBundles()
{
$ bundles = array(
new Symfony\Bundle\\ \\ FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony \Bundle\MonologBu​​ndle\MonologBu​​ndle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraB undle\JMSDiExtraBundle($ this),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),

);

if(in_array($ this-> getEnvironment(),array('dev','test'))){
$ bundles [] = new Symfony\Bundle\ WebProfilerBundle\WebProfilerBundle();
$ bundles [] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$ bundles [] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$ bundles [] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
}

return $ bundles;
}

public function registerContainerConfiguration(LoaderInterface $ loader)
{
$ loader-> load(__ DIR __。'/ config / config _'。$ this-> ; getEnvironment())。 'YML。';
}

public function getCharset()
{
return'UTF-8';
}
}

正在加载的第一个夹具:


 使用Doctrine\Common\DataFixtures\AbstractFixture,
Doctrine\Common\DataFixtures\OrderedFixtureInterface,
Doctrine\Common\Persistence\ObjectManager;

使用Symfony\Component\DependencyInjection\ContainerAwareInterface,
Symfony\Component\DependencyInjection\ContainerInterface;

使用Acme\CoreBundle\Entity\User;

class LoadUserData extends AbstractFixture implements OrderedFixtureInterface,ContainerAwareInterface
{
private $ container;

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

public function load(ObjectManager $ manager)
{
// Do stuff
}

public function getOrder ()
{
return 1;
}
}

我不知道在哪里看, code> composer update 正在运行。



任何想法?

解决方案

此问题中找到解决方案DoctrineFixturesBundle的存储库。



重新排列依赖关系并使用另一个版本的 doctrine / data-fixtures 解决了这个问题。 / p>

我在我的 composer.json 中替换了这些行:

 code>require:{
doctrine / data-fixtures:2.0.*@dev,
doctrine / doctrine-fixtures-bundle:dev-master
}

 require:{
doctrine / doctrine-fixtures-bundle:dev-master,
doctrine / data-fixtures:1.0。* @ ALPHA
}

e灯具正在加载。


After updating a project from Symfony 2.0.22 to 2.1.8 I get this error when executing doctrine:fixtures:load via Terminal

Fatal error: Class 'Doctrine\Common\DataFixtures\Loader' not found in {symfony_install_folder}/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php on line 27

The fixtures worked on 2.0.22 and I've checked the official documentation to see if I've set everything correctly

My composer.json looks like this:

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.1.8",
        "doctrine/orm": ">=2.2.3,<2.5-dev",
        "doctrine/dbal": "2.3.*@dev",
        "doctrine/doctrine-bundle": "1.1.*",
        "twig/extensions": "1.0.*@dev",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.1.*",
        "symfony/monolog-bundle": "2.1.*",
        "sensio/distribution-bundle": "2.1.*",
        "sensio/framework-extra-bundle": "2.1.*",
        "sensio/generator-bundle": "2.1.*",
        "jms/security-extra-bundle": "1.2.*",
        "jms/di-extra-bundle": "1.1.*",
        "kriswallsmith/assetic": "1.1.*@dev",
        "doctrine/common": "2.4.*@dev",
        "doctrine/data-fixtures": "2.0.*@dev",
        "doctrine/doctrine-fixtures-bundle" : "dev-master",
        "gedmo/doctrine-extensions": "2.3.*@dev",
        "stof/doctrine-extensions-bundle" : "1.1.*@dev",
        "friendsofsymfony/jsrouting-bundle": "1.1.*@dev"

    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "branch-alias": {
            "dev-master": "2.1-dev"
        }
    }
}

And my app/AppKernel.php

<?php

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

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            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 Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
            new JMS\AopBundle\JMSAopBundle(),
            new JMS\DiExtraBundle\JMSDiExtraBundle($this),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            new FOS\JsRoutingBundle\FOSJsRoutingBundle(),

        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
            $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
        }

        return $bundles;
    }

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

    public function getCharset()
    {
        return 'UTF-8';
    }
}

The first fixture being loaded:

use Doctrine\Common\DataFixtures\AbstractFixture,
    Doctrine\Common\DataFixtures\OrderedFixtureInterface,
    Doctrine\Common\Persistence\ObjectManager;

use Symfony\Component\DependencyInjection\ContainerAwareInterface,
    Symfony\Component\DependencyInjection\ContainerInterface;

use Acme\CoreBundle\Entity\User;

class LoadUserData extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
{
    private $container;

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

    public function load(ObjectManager $manager)
    {
        // Do stuff
    }

    public function getOrder()
    {
        return 1;
    }
}

I can't figure out where to look, composer update is running just fine.

Any thoughts?

解决方案

Found the solution in this issue on the repository of DoctrineFixturesBundle.

Rearranging the dependancies and using another version of doctrine/data-fixtures solved the problem.

I replaced these lines in my composer.json:

"require": {
    "doctrine/data-fixtures": "2.0.*@dev",
    "doctrine/doctrine-fixtures-bundle" : "dev-master"
}

with

"require": {
    "doctrine/doctrine-fixtures-bundle" : "dev-master",
    "doctrine/data-fixtures": "1.0.*@ALPHA"
}

And the fixtures are being loaded again.

这篇关于更新到Symfony 2.1.8之后,教条装置不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆