加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Autoloader预期类Symfony2

发布时间:2020-12-13 18:24:58 所属栏目:PHP教程 来源:网络整理
导读:我正在使用symfony 2.3框架,自动加载器声称已找到该文件,但没有类: RuntimeException: The autoloader expected class "SensioBundleFrameworkExtraBundleRequestParamConverterDateTimeParamConverter" to be defined in file "/home/na/auth/vendor/
我正在使用symfony 2.3框架,自动加载器声称已找到该文件,但没有类:
RuntimeException: The autoloader expected class "SensioBundle
FrameworkExtraBundleRequestParamConverterDateTimeParamConverter" 
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 SensioBundleFrameworkExtraBundleRequestParamConverter;

use SensioBundleFrameworkExtraBundleConfigurationConfigurationInterface;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpKernelExceptionNotFoundHttpException;
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示例并复制/粘贴全班,您可能不会注意到(因为我没有).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读