繁体   English   中英

Symfont 2.8中的错误-无法重新声明类Symfony \\ Component \\ DependencyInjection \\ ContainerAwareInterface

[英]Error in Symfont 2.8 - Cannot redeclare class Symfony\Component\DependencyInjection\ContainerAwareInterface

您可以在这个问题上帮助我吗?我将Symfont 2.8EasyAdminBundle一起使用 我曾被本手册用来安装-symfony2-admin-panel-in-30-seconds

管理面板工作正常,但是当我尝试创建我的(非管理员)类时,出现错误: 无法在/ var / www / html / Legendcorp / app / cache / dev /中重新声明类Symfony \\ Component \\ DependencyInjection \\ ContainerAwareInterface 6568行的classes.php

例如:我在/src/AppBundle/Controller/APIController.php中创建了该类

namespace AppBundle\Controller;
use JavierEguiluz\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;



class FormController extends BaseAdminController{
    /**
     * @Route("/form/save", name="save")
     */
    public function formAction(Request $request){

    }

}

但是当我尝试申请该课程时,出现错误。 -

  • Fatal error: Cannot redeclare class Symfony\\Component\\DependencyInjection\\ContainerAwareInterface in /var/www/html/Legendcorp/app/cache/dev/classes.php on line 6568

如果我清除了缓存( rm -rf app / cache / * ),它将起作用, 但前提是您不与管理面板联系。

这是我的composer.json文件:

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-4": { "": "src/" },
    "files": [ "app/AppKernel.php" ]
},
"require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.8.*",
    "doctrine/orm": "^2.4.8",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "friendsofsymfony/user-bundle": "1.3@dev",
    "vich/uploader-bundle": "^0.14.0"
},
"require-dev": {
    "sensio/generator-bundle": "~3.0",
    "symfony/phpunit-bridge": "~2.7"
},
"scripts": {
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-update-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ]
},
"config": {
    "bin-dir": "bin"
},
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "symfony-assets-install": "relative",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.8-dev"
    }
}

}

拜托,你能帮我吗?

您关注的博客文章非常好,但是对于诸如安装捆绑软件之类的事情,我始终建议您遵循官方文档。 在这种情况下: 第1章。从EasyAdmin的文档进行安装

关于ContainerAwareInterface错误,我想说它与包无关。 我们不会在任何地方使用该接口,也不会使用ContainerAware类。 如果删除捆绑包,Symfony应用程序是否可以正常运行?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM