iwai / phalcon-router-adapter-config
1.0.0
2015-03-18 07:44 UTC
Requires
- php: >=5.3.6
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-11-27 09:59:02 UTC
README
Provides the ability to perform the Routing from configuration
Install
{ "require": { "iwai/phalcon-mvc-router-config": "*" } }
Recommended
Recommended the use of Phalcon\Config\Adapter\Yaml in incubator, of course, it is possible even otherwise.
Example configuration of yaml file.
# Example: # user_view: # method: [ GET, POST ] # url: /user/view/{user_id} # controller: user # action: view # namespace: \App\FrontendController # Route for UserController::indexAction mapped url for /user user_index: method: GET url: /user controller: user action: index # Same as in the example above, can be omitted `index` and `url`,`controller`,`action` user: method: GET # Route for UserController::viewAction mapped url for /user/view user_view: method: GET # Route for ShopController::viewAction, mapped url for /shop/view/1234 # can be define names to route parameters # see: http://docs.phalconphp.com/en/latest/reference/routing.html#parameters-with-names shop_view: method: GET url: /shop/view/{shop_id} shop_create: method: [ GET, POST ] url: /shop/create
$di['router'] = function() { // Use the config router $router = new \Phalcon\Mvc\Router\Config(); $router->build( new Phalcon\Config\Adapter\Yaml('path/route.yml') ); return $router; };