Download the PHP package adrosoftware/lmrp-loader without Composer
On this page you can find all versions of the php package adrosoftware/lmrp-loader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adrosoftware/lmrp-loader
More information about adrosoftware/lmrp-loader
Files in adrosoftware/lmrp-loader
Package lmrp-loader
Short Description Laminas Mezzio helper class to load routes files and pipelines.
License MIT
Homepage http://github.com/adrosoftware/lmrp-loader
Informations about the package lmrp-loader
Laminas Mezzio Routes and Pipeline Loader
Purpose
When building a medium to large applications on Laminas Mezzio is better if you can organize your routes. By default mezzio define all the routes in the routes.php file under the config directory. For me is better if you can at least organize the routes by modules of routes prefix. For example routes.web.php for all the web routes and routes.api.php for all the api routes.
Usage
The public/index.php file by default look like this:
Assuming you have config/routes.web.php and config/routes.api.php and so on, then replace:
With something like this:
Prefixing routes.
Since version 1.1 now you can use the name of the file to prefix the routes inside them. We create and inject a Prefixer class that behind the scenes uses the \Mezzio\Application $app to generate the routes.
For example let say you have routes.web.php and routes.api.php, in your index.php you use the prefix method instead of the load one, like this:
Then in your routes.web.php and routes.api.php you replace the definition of the anonymous function from
to
Now you are ready to use the $prefixer instead of the $app to create the routes:
As you can see, you can avoid typing /api on all the routes.
NOTE: If you don't want to prefix your route with
/apithen you can just use\Mezzio\Application $appnormally.