升级后 psr4 的变化 class 未找到 symfony 2,4 -> 2,8
psr4 changes after upgrade have class not found symfony 2,4 -> 2,8
我用 "symfony/symfony": "~2.4",
和配置
"autoload": {
"psr-0": { "": "src/", "Mea":"vendor/", "mea":"vendor/Mea/CoreBundle/", "Place":"vendor/Mea/" }
},
我用 "symfony/symfony" 创建新项目:“2.8.x-dev”,
首先我得到错误
[InvalidArgumentException]
a non-empty PSR-4 prefix must end with a namespace separator.
所以我加
"autoload": {
"psr-4": { "": "src/","Mea\":"vendor/", "mea\":"vendor/Mea/CoreBundle/", "SymfonyStandard\": "app/SymfonyStandard/" }
},
并且有 ClassNotFoundException
当我尝试访问此文件夹中的 类 时
示例:
$a = \mea\pattern\view::inst();
给我的
Attempted to load class "view" from namespace "mea\pattern".
Did you forget a "use" statement for "mea\pattern\view"?
500 Internal Server Error - ClassNotFoundException
如何解决?
您配置的命名空间是"Mae"(驼峰式),但在代码中您使用"mae"(小写)。 PSR-4区分大小写:
All class names MUST be referenced in a case-sensitive fashion.
我用 "symfony/symfony": "~2.4", 和配置
"autoload": {
"psr-0": { "": "src/", "Mea":"vendor/", "mea":"vendor/Mea/CoreBundle/", "Place":"vendor/Mea/" }
},
我用 "symfony/symfony" 创建新项目:“2.8.x-dev”,
首先我得到错误
[InvalidArgumentException]
a non-empty PSR-4 prefix must end with a namespace separator.
所以我加
"autoload": {
"psr-4": { "": "src/","Mea\":"vendor/", "mea\":"vendor/Mea/CoreBundle/", "SymfonyStandard\": "app/SymfonyStandard/" }
},
并且有 ClassNotFoundException
当我尝试访问此文件夹中的 类 时
示例:
$a = \mea\pattern\view::inst();
给我的
Attempted to load class "view" from namespace "mea\pattern".
Did you forget a "use" statement for "mea\pattern\view"?
500 Internal Server Error - ClassNotFoundException
如何解决?
您配置的命名空间是"Mae"(驼峰式),但在代码中您使用"mae"(小写)。 PSR-4区分大小写:
All class names MUST be referenced in a case-sensitive fashion.