- 添加路由注解基础类 Get、Post、Put、Delete - 实现路由前缀和版本控制注解 Prefix、Version - 添加中间件和路由名称注解 Middleware、Name - 创建路由服务提供者 RouteServiceProvider - 实现控制器目录扫描和路由自动注册 - 添加配置文件支持控制器目录自定义 - 完善单元测试和集成测试用例 - 添加测试控制器和相关测试代码 - 配置 composer 自动加载和 laravel 服务提供者 - 添加 phpunit 测试配置和基础测试用例
36 lines
641 B
PHP
36 lines
641 B
PHP
<?php
|
|
|
|
namespace Jltx\Routes\Tests\Fixtures\Controllers;
|
|
|
|
use Jltx\Routes\Attribute\Get;
|
|
use Jltx\Routes\Attribute\Middleware;
|
|
use Jltx\Routes\Attribute\Post;
|
|
use Jltx\Routes\Attribute\Prefix;
|
|
use Jltx\Routes\Attribute\Version;
|
|
|
|
#[Prefix('api')]
|
|
#[Version('v2')]
|
|
#[Middleware('auth')]
|
|
class TestController
|
|
{
|
|
#[Get('users')]
|
|
public function getUsers()
|
|
{
|
|
return 'get users';
|
|
}
|
|
|
|
#[Post('users')]
|
|
#[Middleware('admin')]
|
|
public function createUser()
|
|
{
|
|
return 'create user';
|
|
}
|
|
|
|
#[Get('posts/{id}')]
|
|
#[Version('v3')]
|
|
public function getPost()
|
|
{
|
|
return 'get post';
|
|
}
|
|
}
|