在我试图实例化它们时,通过composer管理的类不存在,这是在控制器中。
我的Zendframework 1.12.8文件/目录结构如下:
project
- application
- public
- index.php
- library
- vendor
- composer.json
- composer.lock
我的index.php文件的内容是:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Composer autoloader */
if (file_exists(realpath(APPLICATION_PATH . '/../vendor/autoload.php'))) {
require_once realpath(APPLICATION_PATH . '/../vendor/autoload.php');
}
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
composer autoload.php包含在内,但似乎被Zend_Application忽略或覆盖。根据我看到的博客,这是包含它的正确位置。有线索吗?
右侧。一位同事找到了解决方案:我们需要在实例化composer托管类时为composer使用的命名空间加前缀。因此new VimeoVimeo($foo, $bar)
起作用,或者将use VimeoVideo
放在创建实例new Vimeo($foo, $bar)
之前。