yiiboot/routing 问题修复 & 功能扩展

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

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

yiiboot/routing

最新稳定版本:v1.0.0

Composer 安装命令:

composer require yiiboot/routing

包简介

the yii3 attribute routing

README 文档

README

YiiBoot Routing


An way to define an route with the Route PHP attribute. This allows to configure the route inside its class, without having to add any configuration in external files

Requirements

  • PHP 8.1 or higher.

Installation

The package could be installed with composer:

composer require yiiboot/routing

General usage

the config/params.php

return [
    // ...
    'yiiboot/attributed' => [
        'paths' => [
            dirname(__DIR__) . '/src/Controller'
        ]
    ]
];

the src/Controller/CustomController.php

namespace App\Controller;

use Yiiboot\Routing\Attribute\Route;use Yiisoft\Router\CurrentRoute;

#[Route('/customs', name:'customs.', middleware: [
    FormatDataResponseAsJson::class
])]
final class CustomController
{
    #[Route('/{page:\d+}', name: 'list', method: 'GET', defaults: ['page' => 1])]
    public function list(): ResponseInterface
    {
        // ...
    }

    #[Route('/{id:\d+}', name: 'view', method: 'GET')]
    public function view(CurrentRoute $route): ResponseInterface
    {
        $id = $route->getArgument('id');
        // ...
    }

    #[Route(name: 'create', method: 'POST')]
    public function create(): ResponseInterface
    {
        // ...
    }

    #[Route('/{id:\d+}', name: 'delete', method: 'DELETE')]
    public function delete(CurrentRoute $route): ResponseInterface
    {
        $id = $route->getArgument('id');
        // ...
    }
}

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

Code style

Use Rector to make codebase follow some specific rules or use either newest or any specific version of PHP:

./vendor/bin/rector

Dependencies

Use ComposerRequireChecker to detect transitive Composer dependencies.

License

The Yii Routing is free software. It is released under the terms of the Apache-2.0 License. Please see LICENSE for more information.

Maintained by Yii Boot.

Support the project

Open Collective

Follow updates

Official website

Inspired && Thanks

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2022-11-27