esase/tiny-router 问题修复 & 功能扩展

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

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

esase/tiny-router

Composer 安装命令:

composer require esase/tiny-router

包简介

Flexible routing system component for HTTP and console applications

README 文档

README

Build Status Coverage Status

Tiny/Routing - it's a layer between the outside world like a browser or a console command CLI and your application. The package may be integrated to any existing php project and it does not require any extra packages.

Usually routing contains of two main parts:

  1. Routes - which describe a meta information like - a query, a query type, and a responsible controller which processes all incoming requests.

  2. A Router - just holds registered routes and matches incoming requests with registered routes.
    So it just returns either a matched route or trigger an Exception when a route is not found.

Current implementation of routing is very simple but in the same time very powerful. It gets you a possibility to work with it using a plain requests (literal) and Regexp based requests, also it supports filtering requests by http requests types like: GET, POST, etc.
Also you can use it as a routing for you CLI projects.

So let's check a look an http routing example:

    // create an instance of the router
    $router = new Router(new RequestHttpParams($_SERVER));

    // a literal `home` route
    $router->registerRoute(new Route(
        '/',
        'HomeController',
        'index'
    ));

    // a literal `users` route which accepts only `GET` and `POST` requests
    $router->registerRoute(new Route(
        '/users',
        'UserController',
        // list of actions
        [ 
            'GET' => 'list',
            'POST' => 'create'
        ]
    ));

    // a more complex example using a `RegExp` rule
    $router->registerRoute(new Route(
        '|^/users/(?P<id>\d+)$|i', // it's matches to: `/users/1`, `/users/300`, etc
        'UserController',
        [
            'GET' => 'view', 
            'DELETE' => 'delete',
        ],
        'regexp', 
        ['id']
    ));

    // now get a matched route 
    $matchedRoutes = $router->getMatchedRoute();

Installation

Run the following to install this library:

$ composer require esase/tiny-router

Documentation

https://tiny-docs.readthedocs.io/en/latest/tiny-router/docs/index.html

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固