2017 © Pedro Peláez
 

library microrouter

A mirco & powerful router library for PHP

image

dongnan/microrouter

A mirco & powerful router library for PHP

  • Friday, August 4, 2017
  • by dongnan
  • Repository
  • 1 Watchers
  • 1 Stars
  • 224 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 7 % Grown

The README.md

MicroRouter - 一个PHP路由

MicroRouter 是一个简单的PHP路由,方便进行 RESTful WEB应用和接口开发,同时支持cli方式执行。, (*1)

环境要求

  • PHP >= 5.4

安装

composer 安装

MicroRouter 可以通过 composer 安装,使用以下命令从 composer 下载安装 MicroRouter, (*2)

``` bash $ composer require dongnan/microrouter, (*3)

## 手动下载安装
### 下载地址
- 在 `Git@OSC` 下载 http://git.oschina.net/dongnan/MicroRouter/tags
- 在 `GitHub` 下载 https://github.com/dongnan/MicroRouter/releases

### 安装方法
在你的入口文件中引入

<?php //引入 MicroRouter 的自动加载文件 include("path_to_linkcache/autoload.php");, (*4)


# 如何使用 ### *"Hello World"* ```php <?php require_once __DIR__ . '/vendor/autoload.php'; $router = new \MicroRouter\Router(); $router->respond('GET', '/hello-world', function () { return 'Hello World!'; }); $router->dispatch();

响应所有request_method

<?php
$router->respond('/hello-world', function () {
    return 'Hello World!';
});

参数命名

<?php
$router->respond('/[:name]', function ($params) {
    return 'Hello ' . $params['name'];
});

RESTful

<?php
$router->respond('GET', '/users', $callback);
$router->respond('POST', '/users', $callback);
$router->respond('PUT', '/users/[i:id]', $callback);
$router->respond('DELETE', '/users/[i:id]', $callback);
//匹配多个请求
$router->respond(array('GET','POST'), '/path', $callback);

server配置

nginx

在虚拟主机的配置的server内添加以下配置, (*5)

location / {
  try_files $uri $uri/ /index.php?$args;
}

LICENSE

使用非常灵活宽松的 New BSD License 协议, (*6)

The Versions

04/08 2017

dev-master

9999999-dev http://github.com/dongnan/MicroRouter/

A mirco & powerful router library for PHP

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

by Avatar dongnan

library router microrouter

04/08 2017

0.2.2

0.2.2.0 http://github.com/dongnan/MicroRouter/

A mirco & powerful router library for PHP

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

by Avatar dongnan

library router microrouter

07/07 2017

dev-develop

dev-develop http://github.com/dongnan/MicroRouter/

A mirco & powerful router library for PHP

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

by Avatar dongnan

library router microrouter

07/07 2017

0.2.1

0.2.1.0 http://github.com/dongnan/MicroRouter/

A mirco & powerful router library for PHP

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

by Avatar dongnan

library router microrouter

07/07 2017

0.2.0

0.2.0.0 http://github.com/dongnan/MicroRouter/

A mirco & powerful router library for PHP

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

by Avatar dongnan

library router microrouter

16/05 2016

0.1.2

0.1.2.0 http://github.com/dongnan/MicroRouter/

A mirco & powerful router library for PHP

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

by Avatar dongnan

library router microrouter

14/05 2016

0.1.1

0.1.1.0 http://github.com/dongnan/MicroRouter/

A mirco & powerful router library for PHP

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

by Avatar dongnan

library router microrouter