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
Is your feature request related to a problem? Please describe.
Current MVC routers have the problem that when there are many paths, there is a performance penalty due to the use of regular expressions.
Describe the solution you'd like
Replace the use of regular expressions with arrays
Describe alternatives you've considered
Declare a constant array with paths, a simple example:
\* PATHS contains url paths as key, controllers and actions are defined
in a value array, i.e. ['path'] => [controller, action] */
constPATHS = [
'/cont2/show' => ['SecondController', 'show'],
'/cont4/delete' => ['FourthController', 'delete'],
// ....
];
functionurlPath()
{
$uri = newUri($_SERVER['REQUEST_URI']);
$parts = explode('/', $uri->getPath());
$controller = $parts[1] ?? "index";
$action = $parts[2] ?? "indexAction";
return "/$controller/$action";
];
}
The increase of performance is notorius. Furthermore, it can be extra optimized by splitting PATHS into module arrays to create microcollections, it can process variables (with regex), etc. In this way, Phalcon could handle many paths with Phalcon speed and performance!
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Current MVC routers have the problem that when there are many paths, there is a performance penalty due to the use of regular expressions.
Describe the solution you'd like
Replace the use of regular expressions with arrays
Describe alternatives you've considered
Declare a constant array with paths, a simple example:
Then, to match and execute the routes:
The increase of performance is notorius. Furthermore, it can be extra optimized by splitting
PATHS
into module arrays to create microcollections, it can process variables (with regex), etc. In this way, Phalcon could handle many paths with Phalcon speed and performance!The text was updated successfully, but these errors were encountered: