exe*_*i0n 2 fixtures symfony doctrine-orm symfony-2.1
将项目从Symfony 2.0.22更新到2.1.8后,doctrine:fixtures:load通过终端执行时出现此错误
致命错误:第27行的{symfony_install_folder} /vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php中找不到类'Doctrine\Common\DataFixtures\Loader'
夹具在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": "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"
}
}
}
Run Code Online (Sandbox Code Playgroud)
还有我的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';
}
}
Run Code Online (Sandbox Code Playgroud)
第一个装载夹具:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚在哪里看,composer update运行得很好.
有什么想法吗?
在DoctrineFixturesBundle的存储库中找到了此问题的解决方案.
重新排列依赖项并使用另一个版本doctrine/data-fixtures解决了问题.
我在composer.json中替换了这些行:
"require": {
"doctrine/data-fixtures": "2.0.*@dev",
"doctrine/doctrine-fixtures-bundle" : "dev-master"
}
Run Code Online (Sandbox Code Playgroud)
同
"require": {
"doctrine/doctrine-fixtures-bundle" : "dev-master",
"doctrine/data-fixtures": "1.0.*@ALPHA"
}
Run Code Online (Sandbox Code Playgroud)
并且装置再次被装载.
| 归档时间: |
|
| 查看次数: |
3522 次 |
| 最近记录: |