【问题标题】:InvalidArgumentException Synfomy2InvalidArgumentException Synfomy2
【发布时间】:2017-12-18 09:20:35
【问题描述】:

我正在尝试创建一个 Doctrine 实体:

php app/console doctrine:generate:entity --entity="AWStudio:Category" --fields="name:string(255)" --no-interaction

但我不能,这个回报:

[InvalidArgumentException] 捆绑包“AWStudio”不存在或未启用。也许您忘记将它添加到 AppKernel.php 文件的 registerBundles() 方法中?

有我的APPKernel.php

<?php

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

class AppKernel extends Kernel
{
    public function __construct($environment, $debug)
    {
        date_default_timezone_set('Europe/Paris');
        parent::__construct($environment, $debug);
    }

    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 Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new AWStudio\AWCoreBundle\AWCoreBundle(),
            new \FOS\UserBundle\FOSUserBundle(),
            new \AWStudio\AWUserBundle\AWUserBundle(),
            new AWStudio\CKSBundle\AWStudioCKSBundle(),
            new JMS\AopBundle\JMSAopBundle(),
            new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
            new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
            new FOS\JsRoutingBundle\FOSJsRoutingBundle,
            new JMS\SerializerBundle\JMSSerializerBundle(),
            new Liuggio\ExcelBundle\LiuggioExcelBundle(),
            new JMS\TwigJsBundle\JMSTwigJsBundle(),
            new RaulFraile\Bundle\LadybugBundle\RaulFraileLadybugBundle(),
            new JMS\DiExtraBundle\JMSDiExtraBundle($this),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            new \Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
            new \Fresh\Bundle\DoctrineEnumBundle\FreshDoctrineEnumBundle(),
            new Corley\MaintenanceBundle\CorleyMaintenanceBundle(),
            new Sonata\CoreBundle\SonataCoreBundle(),
            new Sonata\BlockBundle\SonataBlockBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
            new Sonata\AdminBundle\SonataAdminBundle()
        );

        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();
        }

        return $bundles;
    }

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

谢谢! :)

【问题讨论】:

  • 检查您的供应商文件夹并确保捆绑包在那里?
  • 在我的供应商文件夹中,我有:awstudio,所以我试图通过 awstudio 更改命令 AWStudio 但这会返回相同的错误:/

标签: php html css symfony doctrine-orm


【解决方案1】:

您需要将包的完整名称提供给命令。 AWStudio 实际上是您的供应商名称。

我可以看到您在 AWStudio 供应商中有三个捆绑包:AWCoreBundleAWUserBundleCKSBundle

假设您想在AWCoreBundle 中添加您的实体,命令如下:

php app/console doctrine:generate:entity --entity="AWStudioAWUserBundle:Category" --fields="name:string(255)" --no-interaction

注意 AWStudio 之后的 AWUserBundle 包名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-11
    • 2016-05-17
    • 2018-08-16
    • 1970-01-01
    • 1970-01-01
    • 2013-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多