基本上,我想使用Composer自动加载器(用于加载第三方库),但我想继续使用Zend中的自动加载内置机制1.12Zend 1.12中使用Composer自动加载器(用于加载外部库)?
我添加了以下一块代码:
<?php // File path: index.php
// ...
$composerAutoloaderPaths = array(
'../vendor/autoload.php',
'../../common/vendor/autoload.php' // store common libraries used by multiple projects, currently that's working by adding the directory in set_include_path()
);
foreach($composerAutoloaderPaths as $composerAutoloaderPath)
{
if(file_exists($composerAutoloaderPath))
{
require_once $composerAutoloaderPath;
}
else
{
// handle the error gracefully
}
}
// ...
而且,我使用Zend_Loader_Autoloader
这样的:
<?php // File path: Bootstrap.php
// ...
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Plugin_');
$autoloader->registerNamespace('Helper_');
// etc.
// ...
有什么担心使用作曲家和Zend自动加载这个样子?在bootstrap.php中