Skip to content

Introduction and Why Use This Package? #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 6.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
[![Latest Unstable Version](https://poser.pugx.org/LaravelCollective/annotations/v/unstable.svg)](https://packagist.org/packages/laravelcollective/annotations)
[![License](https://poser.pugx.org/LaravelCollective/annotations/license.svg)](https://packagist.org/packages/laravelcollective/annotations)

### Introduction

The Annotations package by Laravel Collective allows developers to define routes, event listeners, and model bindings using PHP annotations inside Controller, Event handler, and Model classes. Eliminating the need for manual route registration and event handling configuration outside of those classes. By scanning specific classes and applying predefined annotations, this package automates essential parts of your Laravel application, making it more concise and easier to maintain.

### Why Use This Package?

- **Simplifies Route Registration**: Define your routes directly within controller methods using annotations like `@Get`, `@Post`, and `@Resource`, reducing the need for explicit route definitions in `routes/web.php`.

It scans the controllers listed in the `$scanRoutes` array of your `AnnotationsServiceProvider`; or scan all controllers in `\App\Http\Controllers` with `$scanControllers = true`.
- **Automates Event Handling**: Use @Hears to attach event listeners directly to methods inside your event handler classes, and the package will scan the classes listed in `$scanEvents` to register them automatically. You no longer need to define event listeners manually by mapping them in `EventServiceProvider::$listen`.
- **Enhances Model Binding**: Automatically bind models to route parameters using `@Bind`, eliminating the need for manual `Route::model()` definition in `AppServiceProvider::boot()`. It scans models listed in `$scanModels`.
- **Customizable and Extensible**: Define your own annotation classes to extend functionality according to your application's needs.
- **Scalable Scanning Mechanism**: Choose between scanning specific controllers, models, or events, or enabling `scanEverything` for automatic detection across your application's namespace.

# Annotations

- [Installation](#installation)
Expand Down