【发布时间】:2017-07-04 14:11:40
【问题描述】:
我在[root]/composer.json 文件中有以下类自动加载定义:
{
...
"autoload": {
"psr-0": {
"": [
"application/models",
"application/controllers",
"application/forms",
"library/"
]
},
"psr-4": {
"": ["src/"]
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
...
}
当我调用[root]/public_html/index.php 页面时,出现以下错误:
PHP 致命错误:未捕获的错误:在 /var/www/html/application/bootstrap.php:29 中找不到类“classes\DependencyInjection”
[root]/public_html/index.php 中的代码如下:
$bootstrap = true;
require_once '../application/bootstrap.php';
[root]/application/bootstrap.php 文件中的内容是:
// turn on autoloading for classes
// composer autoloader
include(MMIPATH.'/vendor/autoload.php');
// zend autoload
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$diContainer = new classes\DependencyInjection(services.yaml');
$proxy = $diContainer->get('containerProxy');
这是[root]/library/classes/DependencyInjection.php的定义:
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
USE Symfony\Component\DependencyInjection\Container;
class DependencyInjection extends ContainerBuilder
{
....
}
这里有什么问题?为什么自动加载器找不到那个类?
【问题讨论】:
标签: php composer-php psr-4 psr-0