implements Phalcon\Mvc\RouterInterface, Phalcon\DI\InjectionAwareInterface
Phalcon\Mvc\Router is the standard framework router. Routing is the process of taking a URI endpoint (that part of the URI which comes after the base URL) and decomposing it into parameters to determine which module, controller, and action of that controller should receive the request
$router = new Phalcon\Mvc\Router(); $router->add( "/documentation/{chapter}/{name}.{type:[a-z]+}", array( "controller" => "documentation", "action" => "show" ) ); $router->handle(); echo $router->getControllerName();
Phalcon\Mvc\Router constructor
Sets the dependency injector
Returns the internal dependency injector
Get rewrite info. This info is read from $_GET[‘_url’]. This returns ‘/’ if the rewrite information cannot be read
Sets the URI source. One of the URI_SOURCE_* constants
$router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI);
Set whether router must remove the extra slashes in the handled routes
Sets the name of the default namespace
Returns the name of the default namespace
Sets the name of the default module
Returns the name of the default module
Sets the default controller name
Returns the default controller name
Sets the default action name
Returns the default action name
Sets an array of default paths. If a route is missing a path the router will use the defined here This method must not be used to set a 404 route
$router->setDefaults(array( 'module' => 'common', 'action' => 'index' ));
Returns an array of default parameters
Handles routing information received from the rewrite engine
//Read the info from the rewrite engine $router->handle(); //Manually passing an URL $router->handle('/posts/edit/1');
Adds a route to the router without any HTTP constraint
$router->add('/about', 'About::index');
Adds a route to the router that only match if the HTTP method is GET
Adds a route to the router that only match if the HTTP method is POST
Adds a route to the router that only match if the HTTP method is PUT
Adds a route to the router that only match if the HTTP method is PATCH
Adds a route to the router that only match if the HTTP method is DELETE
Add a route to the router that only match if the HTTP method is OPTIONS
Adds a route to the router that only match if the HTTP method is HEAD
Mounts a group of routes in the router
Set a group of paths to be returned when none of the defined routes are matched
Removes all the pre-defined routes
Returns the processed namespace name
Returns the processed module name
Returns the processed controller name
Returns the processed action name
Returns the processed parameters
Returns the route that matchs the handled URI
Returns the sub expressions in the regular expression matched
Checks if the router macthes any of the defined routes
Returns all the routes defined in the router
Returns a route object by its id
Returns a route object by its name
Returns whether controller name should not be mangled
© 2011–2016 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/2.0.0/api/Phalcon_Mvc_Router.html