【问题标题】:Symfony2 autoloader found file but did not find classSymfony2 自动加载器找到文件但没有找到类
【发布时间】:2013-07-10 19:42:35
【问题描述】:

我正在尝试在没有供应商的情况下安装 symfony2,并且在运行 app_dev.php 时不断收到以下错误:

RuntimeException: The autoloader expected class "Symfony\Component\EventDispatcher\Event" to be defined in file "/var/www/caremonk/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Event.php". The file was found but the class was not in it, the class name or namespace probably has a typo.

我已通过以下方式安装了正确的文件和供应商: php composer.phar 更新 php composer.phar 安装

我还检查了 Symfony2 抱怨的文件,该文件的内容是:

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\EventDispatcher;

/**
 * Event is the base class for classes containing event data.
 *
 * This class contains no event data. It is used by events that do not pass
 * state information to an event handler when an event is raised.
 *
 * You can call the method stopPropagation() to abort the execution of
 * further listeners in your event listener.
 *
 * @author  Guilherme Blanco <guilhermeblanco@hotmail.com>
 * @author  Jonathan Wage <jonwage@gmail.com>
 * @author  Roman Borschel <roman@code-factory.org>
 * @author  Bernhard Schussek <bschussek@gmail.com>
 *
 * @api
 */
class Event
{
   // Some more code
}

这是一个我没有接触过的标准 symfony2 类,所以我对我需要做的事情有点迷茫。我怎样才能摆脱这个错误?

【问题讨论】:

    标签: php symfony autoloader


    【解决方案1】:

    昨晚遇到了类似的问题。禁用和重新启用 APC 似乎可以解决问题。

    【讨论】:

    • 我刚刚重新启动了 apache,无论出于何种原因,它都成功了。您的建议促使我这样做,谢谢!
    • 太棒了!更多的谷歌搜索导致了这个答案stackoverflow.com/questions/3144350/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-14
    • 2020-01-21
    • 2014-05-29
    • 2019-08-30
    • 2019-01-22
    • 1970-01-01
    • 2016-05-06
    相关资源
    最近更新 更多