sasa-b/router 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sasa-b/router

Composer 安装命令:

composer require sasa-b/router

包简介

Lightweight and performant router inspired by laravel's, and phalcon's router.

README 文档

README

Lightweight router inspired by Laravel's and Phalcon's router.

Usage examples

$router = new \Foundation\Routing\Router();

$r->get('/foo', function () {
    echo 'Hello foo!';
});

// here we are utilising cache for performance, if the cache file was not found 
// routes will be registered and the cache file recreated
$router->cache(function (\Foundation\Routing\Router $r) {
    // if you want to collect routes from a file
    // you can set the path to the routes file as a paramater to collectRoutes() method
    // or via setRoutesPath() method
    $r->collectRoutes();
    
    // you can both collect routes and add them one by one, they will be merged
    $r->get('/foo/{bar}', [
        'controller' => 'FooController',
        'action' => 'index',
    ]);
    
    $r->post('/foo/{bar}', 'FooController::store');
});

try {
    // Adding event listeners
    $router->addEventListener('before_match', function(\Foundation\Routing\Router $router) {
        echo "before match";
    });

    $router->addEventListener('after_match', function(\Foundation\Routing\Router $router) {
        echo "after match";
    });

    $dispatcher = $router->catch();

    $dispatcher->dispatch();

} catch (\Foundation\Routing\Exceptions\NotFoundException $e) {
    echo $e->getCode() . " - Page not found";
} catch (\Foundation\Routing\Exceptions\BadHttpMethodException $e) {
    echo $e->getCode() . " - Bad Http Method";
} 

统计信息

  • 总下载量: 25
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固