Zend_Controller Following the PEAR Naming Convention
I am developing a web application using the zend framework. I like how all autoloading works, but I don't really like how Zend_Controller points to controllers by default. I'm looking for a way to get zend_controller to understand my controller class named Controller_User stored in {$ app} /Controller/User.php. Is there anyway I can do this with less extra code?
+1
source to share
2 answers
subclass dispatcher (cited from http://cslai.coolsilon.com/2009/03/28/extending-zend-framework/ )
class Coolsilon_Controller_Dispatcher
extends Zend_Controller_Dispatcher_Standard {
public function __construct() {
parent::__construct();
}
public function formatControllerName($unformatted) {
return sprintf(
'Controller_%s', ucfirst($this->_formatName($unformatted))
);
}
public function formatActionName($unformatted) {
$formatted = $this->_formatName($unformatted, true);
return strtolower(substr($formatted, 0, 1)) . substr($formatted, 1);
}
}
0
source to share
This is certainly not a step-by-step answer, but I believe you can accomplish what you want by subclassing the standard dispatcher class and making a few changes to the functions related to the controller directory and controller objects. Guide to ZF Ref - Subclass Manager
+2
source to share