extends class Phalcon\Mvc\Router
implements Phalcon\Events\EventsAwareInterface, Phalcon\Mvc\RouterInterface, Phalcon\Di\InjectionAwareInterface
A router that reads routes annotations from classes/resources
use Phalcon\Mvc\Router\Annotations; $di->setShared( "router", function() { // Use the annotations router $router = new Annotations(false); // This will do the same as above but only if the handled uri starts with /robots $router->addResource("Robots", "/robots"); return $router; } );
Adds a resource to the annotations handler A resource is a class that contains routing annotations
Adds a resource to the annotations handler A resource is a class that contains routing annotations The class is located in a module
Produce the routing parameters from the rewrite information
Checks for annotations in the controller docblock
Checks for annotations in the public methods of the controller
Changes the controller class suffix
Changes the action method suffix
Return the registered resources
Phalcon\Mvc\Router constructor
Sets the dependency injector
Returns the internal dependency injector
Sets the events manager
Returns the internal event manager
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
Sets the name of the default module
Sets the default controller name
Sets 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( [ "module" => "common", "action" => "index", ] );
Returns an array of default parameters
Adds a route to the router without any HTTP constraint
use Phalcon\Mvc\Router; $router->add("/about", "About::index"); $router->add("/about", "About::index", ["GET", "POST"]); $router->add("/about", "About::index", ["GET", "POST"], Router::POSITION_FIRST);
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
Adds a route to the router that only match if the HTTP method is PURGE (Squid and Varnish support)
Adds a route to the router that only match if the HTTP method is TRACE
Adds a route to the router that only match if the HTTP method is CONNECT
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 matches the handled URI
Returns the sub expressions in the regular expression matched
Checks if the router matches 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–2017 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Router_Annotations.html