php - Symfony2 自动加载器找到文件但没有找到类

标签 php symfony autoloader

我试图在没有供应商的情况下安装 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 类,我还没有接触过,所以我对我需要做的事情有点迷茫。我怎样才能摆脱这个错误?

最佳答案

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

关于php - Symfony2 自动加载器找到文件但没有找到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17579543/

相关文章:

php - 使用 session_register_shutdown() 的目的是什么?

php - 使用 ADLDAP 从 Active Directory 加载用户

php - 在 php 中从 sql 数据库检索数据的问题

php - symfony - 学说 - 恢复我的 bdd 的所有数据,除了少数

symfony - 我可以将 Blade 模板引擎(laravel)与 symfony 一起使用吗?

php - ZF2 2 个同名模块,来自供应商的不同来源

php - 将一段拆分为 160 个字符的文本消息

symfony - JMSSerializer — 按条件排除属性

php - 对模型使用 Zend_Autoloader

php - Composer 自动加载 - 未找到类异常