grafgriffon/php-router 问题修复 & 功能扩展

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

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

grafgriffon/php-router

最新稳定版本:2.1

Composer 安装命令:

composer require grafgriffon/php-router

包简介

HTTP router

README 文档

README

Powerful, flexible web routing for your service.

Installation and Autoloading

This package is installable and PSR-4 autoloadable via Composer as [grafgriffon/php-router][].

Alternatively, [download a release][], or clone this repository, then map the GrafGriffon\PhpRouter\ namespace to the package src/ directory.

Dependencies

This package requires PHP 8.0 or later. It has been tested on PHP 8.0-8.3. We recommend using the latest available version of PHP as a matter of principle.

Example using

<?php

use GrafGriffon\PhpRouter\Route;
use GrafGriffon\PhpRouter\Router;

require_once './vendor/autoload.php';

$router = new Router([], 'games');

$router->addRoutes(
    Router::group('v1',
        Route::make('GET', 'get', function () {
            echo "get\n";
        }),
        Route::make('POST', 'add', function () {
            echo "add\n";
        })
    ),
    Route::make('GET', 'documentation', function () {
        echo "documentation\n";
    })
);
$router->addRoute(Route::make('GET', 'example', function () {
    echo "example\n";
}));

$router->addRoutes(
    Route::make('GET', 'get', function () {
        echo "get\n";
    }),
    Route::make('POST', 'add', function () {
        echo "add\n";
    })
);

$target = $router->match('GET', '/games/v1/get?val=test');

if ($target) {
    $target();
} else {
    echo 'Route not present';
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-03-27