定制 hunomina/http-router-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hunomina/http-router-php

Composer 安装命令:

composer require hunomina/http-router-php

包简介

Implementation of Http Router classes for PHP7.1 or higher

README 文档

README

Build Status

Description : Implementation of Http Router classes for PHP7.1 or higher.

This library is mainly composed of 4 classes.

Router

The Router class handles request by calling the request(string $method, string $url) method which must return a route action response.

Can be instantiate by passing a route file and a type (json, yaml... extend if you want to add new ones).

The Router::request($method, $url) method allows to execute a route action based on the method and the url parameters.

Example of route files here.

RouteManager

The RouteManager parses route files. You can then get Route objects by calling the getRoutes() method.

This class is abstract, so you have to extend it in order to add new route file types (See JsonRouteManager or YamlRouteManager for examples).

Route

A Route object is composed of these attributes :

  • array $_methods : An array of HTTP methods handled by the route
  • string $_url : The url of the route
  • string $_pattern : A regexp representing the urls handled by the route
  • array $_action : A two items array. The first is the FQN of a class (namespaces separated by ':'). The second one is the name of the method you want to call for this route. When setting the action attribute you have to pass a string which respects this syntax classname::method.

Finally, the Route::call() method execute the route action which has to return a Response object.

Response

A Response object is composed of :

  • array $_headers : An array of HTTP headers
  • string $_content : Content of the response

The class is abstract, so you have to extend in order to add new response types

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2018-10-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固