https://github.com/saeeddev94/laravel-annotation
Laravel #[Annotation]
https://github.com/saeeddev94/laravel-annotation
annotation attribute laravel laravel-9 php8
Last synced: about 1 month ago
JSON representation
Laravel #[Annotation]
- Host: GitHub
- URL: https://github.com/saeeddev94/laravel-annotation
- Owner: SaeedDev94
- License: mit
- Created: 2022-01-11T18:36:18.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T11:56:34.000Z (about 1 year ago)
- Last Synced: 2025-04-13T08:58:22.742Z (about 2 months ago)
- Topics: annotation, attribute, laravel, laravel-9, php8
- Language: PHP
- Homepage:
- Size: 50.8 KB
- Stars: 17
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel #[Annotation]
### 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
```bash
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