Php 检测到Symfony异常:找到文件但类不在其中,类名或命名空间可能有输入错误。
自动加载程序希望在文件“C:\wamp64\www\Symfony\vendor\composer/./../src\Sdz\BlogBundle\Controller\DefaultController.php”中定义类“Sdz\BlogBundle\Controller\DefaultController”。找到了文件,但类不在其中,类名或命名空间可能有输入错误。 500内部服务器错误-运行时异常 堆栈跟踪Php 检测到Symfony异常:找到文件但类不在其中,类名或命名空间可能有输入错误。,php,symfony,Php,Symfony,自动加载程序希望在文件“C:\wamp64\www\Symfony\vendor\composer/./../src\Sdz\BlogBundle\Controller\DefaultController.php”中定义类“Sdz\BlogBundle\Controller\DefaultController”。找到了文件,但类不在其中,类名或命名空间可能有输入错误。 500内部服务器错误-运行时异常 堆栈跟踪 in vendor\symfony\symfony\src\Symfony\Comp
in vendor\symfony\symfony\src\Symfony\Component\Debug\DebugClassLoader.php at line 223 -
throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class));
}
throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
}
if (self::$caseCheck) {
$real = explode('\\', $class.strrchr($file, '.'));
如果类的名称与文件名不对应,则会发生此错误 例如:
Sdz\BlogBundle\Controller\DefaultController.php
类名:
class UserController
欢迎来到Stackoverflow,我想让你参考以下指南:你能发布你的类的名称吗?需要这个错误所指的类的代码,请发布defaultController的代码(文件名、命名空间等)defaultControllerI的代码我做了,但它不起作用谢谢Gay,我使用了DeaultController,它起作用了。