PHPackages                             sorry510/annotation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sorry510/annotation

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sorry510/annotation
===================

laravel annotation

v0.0.1(4y ago)08811MITPHPPHP &gt;=7.0.0

Since Feb 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/sorry510/annotation)[ Packagist](https://packagist.org/packages/sorry510/annotation)[ RSS](/packages/sorry510-annotation/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (2)Versions (2)Used By (1)

安装
--

[](#安装)

```
composer require sorry510/annotation

```

使用说明
----

[](#使用说明)

#### 功能

[](#功能)

> 添加了 4 中注解

- `@Validator` 参数验证(只能使用在 `Controller`中)
- `@RequestParam` 添加默认参数，传入同名参数会覆盖默认参数(只能使用在 `Controller`中)
- `@Transaction` 添加事务(只能使用在 `Controller`中)
- `@Inject` 注入属性(注意：循环注入可能会有循环依赖的问题a-&gt;b-&gt;c-&gt;a)

#### 使用前提

[](#使用前提)

- 生成配置文件

```
php artisan vendor:publish --tag=annotation

```

- 在对应的 `Controller` 文件中添加对应的注解的`命名空间`

```
namespace App\Controller;

use Sorry510\Annotations\Validator;
use Sorry510\Annotations\RequestParam;
use Sorry510\Annotations\Transaction;
use Sorry510\Annotations\Inject;

```

- 在 `app\Http\Kernel.php` 添加 `annotation` 中间件

```
