Module-specific routes in Zend Framework without specifying a module name in the route

I need to create some module-specific routes, but without explicitly mentioning the module name in the route. Right now I have a separate configuration file for each module (MODULE / configs / module.ini), and in the bootstrap module I click these routes in the Zend Framework. The INI file contains route information, but mentions the module name in the route. eg.

routes.contents.route = "Contents /(.*)"
routes.contents.defaults.module = Contents
routes.contents.defaults.controller = index
routes.contents.defaults.action = index
+ other route information.

You can see that the module name ("Content") is explicitly indicated in the route. I want that in the routes I mention only part of the module name and automatically add the module name to the route. Therefore, if I rename a module to say CMS, I do not want to change each route to "CMS / xxxx".

+3
source share
1 answer

The route you specify can be whatever you want. If the Zend Framework matches it, it will execute the route based on the default values.

resources.router.routes.products.regex = "somethingawesome/(.*)"
resources.router.routes.products.defaults.module = "ModuleName"
resources.router.routes.products.defaults.controller = "awesome"
resources.router.routes.products.defaults.action = "cool"

The "route" above uses the regular expression for - mysite.com/somethingawesome/whatever and directs it to the module: ModuleName, the controller AwesomeController.php and runs coolAction ()

, "somethingawesome" . , URL- .

0

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