Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法实例化抽象类。。。在appDevDebugProjectContainer.php-Symfony2中_Php_Symfony_Apc - Fatal编程技术网

无法实例化抽象类。。。在appDevDebugProjectContainer.php-Symfony2中

无法实例化抽象类。。。在appDevDebugProjectContainer.php-Symfony2中,php,symfony,apc,Php,Symfony,Apc,我昨天刚刚安装了apc,现在出现以下错误: FatalErrorException: Error: Cannot instantiate abstract class ACME\WebBundle\Menu\MenuBuilder in /var/www/app/cache/dev/appDevDebugProjectContainer.php line 743 在这一行中有: protected function getEposMain_MenuBuilderService() {

我昨天刚刚安装了apc,现在出现以下错误:

FatalErrorException: Error: Cannot instantiate abstract class
ACME\WebBundle\Menu\MenuBuilder in
/var/www/app/cache/dev/appDevDebugProjectContainer.php line 743
在这一行中有:

protected function getEposMain_MenuBuilderService()
{
    return $this->services['epos_main.menu_builder'] = new \ACME\WebBundle\Menu\MenuBuilder($this->get('knp_menu.factory'));
}
有人知道这是什么意思吗?我能用它做什么

服务.yml

services:
    epos_main.menu_builder:
        class: ACME\WebBundle\Menu\MenuBuilder
        arguments: ["@knp_menu.factory"]

    epos_main.menu.main:
        class: Knp\Menu\MenuItem # the service definition requires setting the class
        factory_service: epos_main.menu_builder
        factory_method: createMainMenu
        arguments:
            - @request
            - @twig
            - 'ACMEWebBundle:Menu:menu.html.twig'
        scope: request # needed as we have the request as a dependency here
        tags:
            - { name: knp_menu.menu, alias: main } # The alias is what is used to retrieve the menu

    epos.twig.epos_extension:
        class: ACME\WebBundle\Twig\ePOSTwigExtension
        tags:
            - { name: twig.extension }
一点MenuBuilder类代码:

namespace ACME\WebBundle\Menu;

use Knp\Menu\FactoryInterface;
use Symfony\Component\HttpFoundation\Request;

class MenuBuilder
{
    private $factory;

    /**
     * @param FactoryInterface $factory
     */
    public function __construct(FactoryInterface $factory)
    {
        $this->factory = $factory;
    }

    public function createMainMenu(Request $request)
    {

        $menu = $this->factory->createItem('root');
        $menu->setChildrenAttribute('class', 'nav');
        ...
        ...
        return $menu;
    }
}

这个错误是不言自明的。不能按照OOP规则实例化抽象类


你的
MenuBuilder
是一个
抽象类,你试图用一个
关键字进行实例化,这是不可能的。

如果你的MenuBuilder类在某个时候是抽象的,你把它改成了一个具体的类,有可能APC仍然有旧版本潜伏在内存中


尝试重新启动您的Web服务器。

是否尝试清除缓存?请检查您的
服务。yml
在服务处于非抽象状态时,您似乎将其声明为非抽象。你忘了添加工厂了吗?问题是,一切都很好,我在services.yml和那个类中没有做任何更改。我已经编辑了我的问题,添加了services.yml中的代码和MenuBuilder类的一些代码。如何判断类是否是抽象的?他没有在定义中宣布它是抽象的。。。我目前也遇到了类似的问题。