我通过composer安装了phpoffice / phpexcel软件包 . 无论如何自动加载不起作用 . 我尝试了每个命名空间的组合来调用类,但它不存在:
PHP Fatal error: Class 'PHPExcel\\PHPExcel' not found in
调用它的代码:
$objPHPExcel = new \PHPExcel\PHPExcel();
composer.json看起来不错:
{
"name": "Bjc/Iis",
"description": "A complete software suite for commerce",
"license": "MIT",
"keywords": ["commerce"],
"authors": [
{
"name": "me",
"email": "me@me"
}
],
"require": {
"phpmailer/phpmailer": "5.*",
"components/jquery": "2.*",
"twbs/bootstrap": "3.*",
"zendframework/zend-barcode": "*",
"zendframework/zend-validator": "*",
"phpoffice/phpexcel": "1.8.*"
},
"require-dev": {},
"autoload": {
"psr-4": {
"Bjc\\Iis\\": "src"
}
}
}
“composer update”命令运行得很好 . phpoffice / phpexcel的文件也按预期在vendor / phpoffice / phpexcel中 .
我在我的脚本中调用了composer autoloader,如下所示(它可以在phpmailer中使用):
require_once(__DIR__.'/../vendor/autoload.php');
Phpexcel还在作曲家的所有自动加载器文件中都有引用:
vendor / composer / autoload_static有(除此之外)这些行:
public static $prefixesPsr0 = array (
'P' =>
array (
'PHPExcel' =>
array (
0 => __DIR__ . '/..' . '/phpoffice/phpexcel/Classes',
),
),
);
vendor / composer / autoload_namespaces.php看起来像这样:
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'PHPExcel' => array($vendorDir . '/phpoffice/phpexcel/Classes'),
);
谁能看到我的错误?