saeedpooyanfar/laravel-annotation
最新稳定版本:5.0.0
Composer 安装命令:
composer require saeedpooyanfar/laravel-annotation
包简介
Laravel #[Annotation]
README 文档
README
Introduction
PHP 8.0 release was a revolution for the language.
It brings cool features like Named arguments, Attributes, Constructor property and ...
PHP 8.1 brings even more exciting features like Enumerations, New in initializers, Array unpacking and ...
The idea of this package is using PHP Attribute in a laravel project.
Installing
composer require saeedpooyanfar/laravel-annotation
Setup
In App\Http\Controllers\Controller::class :
Replace use Illuminate\Routing\Controller as BaseController;
With use LaravelAnnotation\BaseController;
Or if you don't want to change your BaseController you can:
Use LaravelAnnotation\AttributeMiddleware trait
In App\Http\Controllers\Controller::class
Middleware attribute
Here is an example that how you can use Middleware attribute in a laravel controller:
<?php use LaravelAnnotation\Attribute\Middleware; #[Middleware(RedirectIfAuthenticated::class, 'sanctum', except: 'logout')] class AuthController extends Controller { public function register() { } public function login() { } #[Middleware(Authenticate::class, 'sanctum')] public function logout() { } }
统计信息
- 总下载量: 2.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-11