PHPackages                             saeedpooyanfar/laravel-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. saeedpooyanfar/laravel-annotation

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

saeedpooyanfar/laravel-annotation
=================================

Laravel #\[Annotation\]

5.0.0(2y ago)182.7k1MITPHPPHP ^8.2

Since Jan 14Pushed 2y ago3 watchersCompare

[ Source](https://github.com/SaeedDev94/laravel-annotation)[ Packagist](https://packagist.org/packages/saeedpooyanfar/laravel-annotation)[ RSS](/packages/saeedpooyanfar-laravel-annotation/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (4)Versions (11)Used By (0)

Laravel #\[Annotation\]
=======================

[](#laravel-annotation)

### Introduction

[](#introduction)

PHP 8.0 release was a revolution for the language.
It brings cool features like [`Named arguments`](https://www.php.net/releases/8.0/en.php#named-arguments), [`Attributes`](https://www.php.net/releases/8.0/en.php#attributes), [`Constructor property`](https://www.php.net/releases/8.0/en.php#constructor-property-promotion) and ...
PHP 8.1 brings even more exciting features like [`Enumerations`](https://www.php.net/releases/8.1/en.php#enumerations), [`New in initializers`](https://www.php.net/releases/8.1/en.php#new_in_initializers), [`Array unpacking`](https://www.php.net/releases/8.1/en.php#array_unpacking_support_for_string_keyed_arrays) and ...
**The idea of this package is using PHP [`Attribute`](https://www.php.net/manual/en/language.attributes.overview.php) in a laravel project.**

### Installing

[](#installing)

```
composer require saeedpooyanfar/laravel-annotation
```

### Setup

[](#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

[](#middleware-attribute)

Here is an example that how you can use `Middleware` attribute in a laravel controller:

```
