jlanger/router

路由器

v3.2.1 2020-10-19 09:25 UTC

This package is auto-updated.

Last update: 2024-09-19 18:01:46 UTC


README

本项目实现了一个基于php的非常简单的路由器。

配置如下

{
  "/homepage": {
    "GET": "homepage.php"
  },
  "/other_page": {
    "*": "other_page.php"
  }
}

这将允许在/homepage上仅使用get方法,并在/other-page上使用所有方法。

配置中的所有路径都必须相对于使用说明部分中提到的索引文档。

使用方法

<?php

include 'vendor/autoload.php';

use JLanger\Router\Router;
use JLanger\Router\JsonRouteStorage;

(new Router(new JsonRouteStorage('config_file.json')))->doRouting($_SERVER);