大家好,我正在尝试使用 zend 框架创建一个休息服务,我基本上复制了这个休息服务将用于的实际应用程序。我删除了布局文件夹和视图文件夹。
我的问题是模块似乎根本没有加载,当我转到 index.php 时得到以下输出
problemInvalid controller specified (error)#0 /home/********/*****/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /home/********/*****/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #2 /home/********/*****/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #3 /home/********/public_html/portal/websvc/index.php(34): Zend_Application->run() #4 {main}
我不确定为什么这不起作用。它与我的原始应用程序具有 20 个模块的设置基本相同,这没有问题。
请帮忙!:'(
所以我基本上有以下文件夹结构
/app/modules
/app/modules/v1
/app/modules/v1/controllers
/app/modules/v1/controllers/OutboundController.php
/app/modules/v1/controllers/ProductController.php
/app/modules/v1/Bootstrap.php
/app/modules/default
/app/modules/default/controllers
/app/modules/default/controllers/errorController.php
/app/config/
这是我的 application.ini
[production]
includePaths.library = APPLICATION_PATH "/../../../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.defaultModule = "v1"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.router.routes.rest.type = Zend_Rest_Route
我的 bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
protected function _initautoloader() {
$autoloader = new Zend_Application_Module_Autoloader(array(
'basePath' => APPLICATION_PATH."/modules/default",
'namespace' => '',
));
$resourceAutoLoader = new Zend_Loader_Autoloader_Resource(array(
'basePath' => APPLICATION_PATH,
'namespace' => '',
));
$resourceAutoLoader->addResourceTypes(array(
"class" => array(
'namespace' => 'Class',
'path' => '/../../../library/Class'
),
"model" => array(
'namespace' => 'Model',
'path' => '/../../../library/Models'
)
));
}
protected function _initFrontModules()
{
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$front->addModuleDirectory(APPLICATION_PATH . '/modules');
}
}
我的 index.php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../../ibwms/applications/external/websvc'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../../../library'),
get_include_path(),
)));
/* Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
try{
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
Zend_Controller_Front::getInstance()->setBaseUrl('/portal/websvc/');
$application->bootstrap()
->run();
}catch(Exception $e)
{
echo 'problem'.$e->getMessage();
}