You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if Phalcon offered a native way to initialize the router component via an array in a similar manner that the config and providers are configured. The current implementation either requires passing around the DI and Router component or defining a file with broken references.
Reasons for Need
Practicality, easier to maintain and similar to other Phalcon patterns.
Separate files for different components, enabled.
Environment based route loading (feature flags).
Smooth integration with build, test, and sniffing tools.
Smooth integration with IDES. No broken references.
Reduce the need for file based loading if defined in a custom namespace. (require_once vs autoload)
Ability to collapse structure in IDE.
Work Around
Below is an extremely raw version of what has to be done to work around the feature request. (Done in 10 minutes for this NFR). By parsing over a data structure and dynamically building the Router Provider, we are able to dynamically build the $router->add() methods.
This method uses constants but in a real working version we should be able to set the config via an env file via a setter.
Request
It would be nice if Phalcon offered a native way to initialize the router component via an array in a similar manner that the config and providers are configured. The current implementation either requires passing around the DI and Router component or defining a file with broken references.
Reasons for Need
Work Around
Below is an extremely raw version of what has to be done to work around the feature request. (Done in 10 minutes for this NFR). By parsing over a data structure and dynamically building the Router Provider, we are able to dynamically build the
$router->add()
methods.This method uses constants but in a real working version we should be able to set the config via an env file via a setter.
RouteConfig.php
The text was updated successfully, but these errors were encountered: