raihel/controller
最新稳定版本:v0.2.1
Composer 安装命令:
composer require raihel/controller
包简介
Create your routes using attributes in your controllers
README 文档
README
Create your routes using attributes in your controllers
Installation
composer install raihel/controller
Setting
Use Controller Factory to map your routes
diretory: An array with the directories of your controllerscontrollers: An array with your controller classesloadRoute: The class that will do the work of including the routes mapped in your controllers in your application accepts any class that implementsRaihel\Controller\Core\Load\Type\LoudRoute
Slim:
require __DIR__.'/../../vendor/autoload.php'; use App\HelloController; use Raihel\Controller\Core\ControllerFactory; use Slim\App; $app = new App(); use Raihel\Controller\Core\Load\Type\SlimLoadRoute; ControllerFactory::load( loadRoute: new SlimLoadRoute($app), diretory: [__DIR__ . '/../src'], controllers: [HelloController::class] ); $app->run();
Lumen:
ControllerFactory::load( loadRoute: new LumenLoadRoute($router), diretory: [__DIR__ . '/../app/Http/Controllers'], );
Usage/Examples
Controller
Create your controller by adding the attribute Controller in your class it can receive a prefix that groups your routes
namespace App; use Raihel\Controller\Attributes\Controller; use Raihel\Controller\Attributes\Route\Get; use Raihel\Controller\Attributes\Route\Put; #[Controller('home')] class AppController { #[Get] public function home() { echo 'Hello World!'; } #[Get('hello'), Put('hello')] public function get2() { echo 'Hello World 2!'; } }
Routes
The attribute Get before the home method creates a GET /home endponit for application
| Attributes |
|---|
| Get |
| Post |
| Put |
| Delete |
| Patch |
Authors
License
The Raihel Controller is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-13