1

你能帮我解决这个问题吗?我使用Symfont 2.8EasyAdminBundle。我使用这本手册来安装 - symfony2-admin-panel-in-30-seconds

管理面板工作正常,但是当我尝试创建我的(非管理员)类时,我收到一个错误:Cannot redeclare class Symfony\Component\DependencyInjection\ContainerAwareInterface in /var/www/html/Legendcorp/app/cache/dev/第 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"
    }
}

}

拜托,你能帮帮我吗?

4

1 回答 1

1

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

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

于 2016-02-03T12:23:25.583 回答