简体   繁体   English

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

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

Can you help me in this question ... I use Symfont 2.8 with EasyAdminBundle . 您可以在这个问题上帮助我吗?我将Symfont 2.8EasyAdminBundle一起使用 I was used this manual to install - symfony2-admin-panel-in-30-seconds . 我曾被本手册用来安装-symfony2-admin-panel-in-30-seconds

Admin panel works fine, but when I try to create my (not-admin) class, I get an error : Cannot redeclare class Symfony\\Component\\DependencyInjection\\ContainerAwareInterface in /var/www/html/Legendcorp/app/cache/dev/classes.php on line 6568 管理面板工作正常,但是当我尝试创建我的(非管理员)类时,出现错误: 无法在/ var / www / html / Legendcorp / app / cache / dev /中重新声明类Symfony \\ Component \\ DependencyInjection \\ ContainerAwareInterface 6568行的classes.php

For example: I created the class in /src/AppBundle/Controller/APIController.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){

    }

}

but when I try to apply to this class, I get an error. 但是当我尝试申请该课程时,出现错误。 - -

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

If I clear the cache ( rm -rf app/cache/* ), it will works, but only as long as you do not contact the admin panel. 如果我清除了缓存( rm -rf app / cache / * ),它将起作用, 但前提是您不与管理面板联系。

This is my composer.json file: 这是我的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"
    }
}

} }

Please, can you help me? 拜托,你能帮我吗?

The blog post you followed is very nice, but for things like installing the bundle, I always recommend to follow the official documentation. 您关注的博客文章非常好,但是对于诸如安装捆绑软件之类的事情,我始终建议您遵循官方文档。 In this case: Chapter 1. Installation from EasyAdmin's docs. 在这种情况下: 第1章。从EasyAdmin的文档进行安装

Regarding the ContainerAwareInterface error, I'd say that it has nothing to do with the bundle. 关于ContainerAwareInterface错误,我想说它与包无关。 We don't use that interface anywhere and we don't use the ContainerAware class either. 我们不会在任何地方使用该接口,也不会使用ContainerAware类。 If you remove the bundle, does the Symfony application work without errors? 如果删除捆绑包,Symfony应用程序是否可以正常运行?

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

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