limingxinleo / x-phalcon-router
a phalcon router component
Installs: 3 048
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.5
- ext-phalcon: ^3.0
Requires (Dev)
- phalcon/dd: ^1.1
- phpunit/phpunit: >=4.8
This package is auto-updated.
Last update: 2024-12-17 19:12:37 UTC
README
a phalcon router component
安装
composer require limingxinleo/x-phalcon-router
配置
添加服务
<?php use Xin\Phalcon\Router\Mvc\Router; $di->setShared('router', function () { $router = new Router(false); // 普通路由 $router->add('/index', 'Tests\\App\\Controllers\\Index::index'); // 默认组使用方式 $group = new \Phalcon\Mvc\Router\Group(); $group->setPrefix('/test'); $group->add('/index', 'Tests\\App\\Controllers\\Index::group'); $router->mount($group); // 匿名函数使用方式 $router->group(function () { $group = new \Phalcon\Mvc\Router\Group(); $group->setPrefix('/test2'); $group->add('/index', 'Tests\\App\\Controllers\\Index::group'); return $group; }); return $router; });