Zend Url and case-sensitive module name

I am writing a Zend application.

I am using the zend command line tool. I created a couple of Default and User modules and marked Default as the default controller in the application configuration file. I also created appropriate index controllers / actions for these two modules.

When I look at the root of the site, everything is in order. But when I look at $site_root$/user , instead of getting information about the index controller, I get errors.

 Notice: Undefined index: user in E:\xampp\php\PEAR\Zend\Controller\Dispatcher\Standard.php on line 384 Message: Invalid controller specified (index) Stack trace: #0 E:\xampp\php\PEAR\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 E:\xampp\php\PEAR\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch() #2 E:\xampp\php\PEAR\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #3 E:\xampp\htdocs\$project$\public\index.php(26): Zend_Application->run() #4 {main} Request Parameters: array ( 'module' => 'user', 'controller' => 'index', 'action' => 'index', ) 

However, when I browse $site_root$/user , everything is OK again. Obviously, the URL must be case sensitive in order to display the module name. I thought of something like this, like re-writing the Zend Request class. But what is the best practice of getting the lowercase module name in the url?

Edit 1: Folder structure:

enter image description here

+4
source share
3 answers

Check the Zend class Zend_Controller_Request_Abstract in the file Zend \ Controller \ Request \ Abstract.php. If there are several modules in a ZF application, you should add ucfirst()

 public function getModuleName() { if (null === $this->_module) { $this->_module = $this->getParam($this->getModuleKey()); } return ucfirst($this->_module); } 
0
source

Perhaps the problem is that you are installing the default module "Default" not "Default" ? Also, the name of your folder should be lowercase, but I never used the command line, so maybe I'm wrong. Rename all module folders to lowercase.

+2
source

Depending on the OS and Server, there are probably some business requirements.

For example, Windows vs linux Paths. On a Linux drive, Paths are case sensitive, and servers, such as the Apahe path structure, are based on the drive path. Any operation associated with the basic disk I / O operation requires strict definition of file names.

Also for URLS, it depends on the server implementation and possibly the plugins. For example, Apache Http is usually case-sensitive, but you can enable mod_spelling ( http://httpd.apache.org/docs/2.2/mod/mod_speling.html ) to make it spell correctly in URLs, for example, in case of work .

It is always good practice to be strict in the names of file / class / method / .... It is also recommended that you use a template (native or not) to be more efficient in your code and structure.

+1
source

Source: https://habr.com/ru/post/1398963/


All Articles