了一段时间,但我发现,这是可以用自定义调度来完成:
<?php
namespace Webjawns\Controller\Dispatcher;
use Zend_Controller_Dispatcher_Standard as Dispatcher;
class Standard extends Dispatcher
{
/**
* Format action class name
*
* @param string $moduleName Name of the current module
* @param string $className Name of the action class
* @return string Formatted class name
*/
public function formatClassName($moduleName, $className)
{
return $this->formatModuleName($moduleName) . '\Controller\\' . $className;
}
/**
* Convert a class name to a filename
*
* @param string $class
* @return string
*/
public function classToFilename($class)
{
return str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
}
}
某处的入口点然后到应用程序:
Zend_Controller_Front::getInstance()->setDispatcher(
new \Webjawns\Controller\Dispatcher\Standard());
不ZF1自动加载器支持自动加载名称空间文件?如果是这样,那么只需将您的控制器转换为名称空间名称,一切都应该仍然有效。我不确定是否自动加载名称空间类。 – 2012-07-27 23:02:20
为了记录,ZF2控制器的正确名称空间应该是'Module \ Controllers' – Sam 2012-07-30 05:19:13
ZF2骨架应用程序使用Application \ Controller \ IndexController([模块名称] /控制器/ [控制器名称]控制器)。 – 2012-07-30 21:18:58