承接 debuss-a/fastroute-router 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

debuss-a/fastroute-router

最新稳定版本:2.0.1

Composer 安装命令:

composer require debuss-a/fastroute-router

包简介

A PSR-15 router implementation using FastRoute as the routing engine.

README 文档

README

A PSR-15 router implementation using nikic/fast-route as the routing engine.

Installation

Install via Composer:

composer require debuss-a/fastroute-router

Requirements

  • PHP 8.2 or higher
  • nikic/fast-route ^1.0

Usage

An example controller :

<?php

namespace Application\Controller;

use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
use Router\Attribute\Method;

class HomePageController extends RequestHandlerInterface
{

    #[Method('/', methods: ['GET'])]
    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $this->logger->info('Displaying home page');

        return $this->response()->view('home');
    }
}

Use the router and attribute route loader in your application:

$request = ServerRequestFactory::fromGlobals();

$dispatcher = simpleDispatcher(function (RouteCollector $collector): void {

    // This part will scan the specified directory for
    // controller classes and load their route attributes
    $loader = new AttributeRouteLoader(
        'Application\\Controller\\',
        source_path('Application/Controller')
    );

    $loader->load($collector);
    
    // You can also add routes manually if needed
    $collector->addRoute('GET', '/about', Application\Controller\AboutPageController::class);

});

$response = $dispatcher->dispatch($request->getMethod(), $request->getUri());

The handler can be :

  • instanceof MiddlewareInterface
  • instanceof RequestHandlerInterface
  • a callable

Testing

This project includes a comprehensive Pest test suite with 87+ passing tests covering all components.

Running Tests

./vendor/bin/pest

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固