php – Autoloader预期类Symfony2

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – Autoloader预期类Symfony2脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用symfony 2.3框架,@L_512_0@加载器声称已找到该文件,但没有类:
RuntimeException: The autoloader expected class "Sensio\Bundle\
FrameworkExtraBundle\Request\ParamConverter\DateTimeParamConverter" 
to be defined in file "/home/na/auth/vendor/sensio/framework-extra-bundle/
Sensio/Bundle/FrameworkExtraBundle/Request/ParamConverter/
DateTimeParamConverter.PHP". The file was found but the class was not in IT,the class name or namespace PRobably has a typo.

这个引用的文件如下所示:

<?PHP

/*
 * This file is part of the Symfony framework.
 *
 * (c) Fabien Potencier <fabien@symfony.COM>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
use Symfony\component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttPException;
use DateTime;

/**
 * Convert DateTime instances From request attribute VARiable.
 *
 * @author Benjamin Eberlei <kontakt@beberlei.de>
 */
class DateTimeParamConverter implements ParamConverterInterface
{
    /**
     * @{inheritdoc}
     * 
     * @throws NotFoundHttpException When invalid date given
     */
    public function apply(Request $request,ConfigurationInterface $configuration)
    {
        $param = $configuration->getName();

        if (!$request->attributes->has($param)) {
            return false;
        }

        $options = $configuration->getOptions();
        $value   = $request->attributes->get($param);

        $date = isset($options['format'])
            ? DateTime::createFromFormat($options['format'],$value)
            : new DateTime($value);

        if (!$date) {
            throw new NotFoundHttpException('Invalid date given.');
        }

        $request->attributes->set($param,$date);

        return true;
    }

    /**
     * @{inheritdoc}
     */
    public function supports(ConfigurationInterface $configuration)
    {
        if (null === $configuration->getClass()) {
            return false;
        }

        return "DateTime" === $configuration->getClass();
    }
}

无论如何,一些可能有用的细节是我最近安装了Doctrine并运行命令……

2028  PHP app/console doctrine:schema:create
 2029  PHP app/console doctrine:generate:entities Auth

在那些命令之后,symfony停止了工作.我不知道这是不是一些奇怪的错误.如果您需要更多信息,我可以发帖.谢谢你的帮助.

缺少(或短)PHP开始标记也可能导致该错误.是的,这听起来很有趣,但如果您只是按照Symfony示例并复制/粘贴全班,您可能不会注意到(因为我没有).

脚本宝典总结

以上是脚本宝典为你收集整理的php – Autoloader预期类Symfony2全部内容,希望文章能够帮你解决php – Autoloader预期类Symfony2所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。