You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-20Lines changed: 32 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,7 @@
2
2
3
3
[](https://packagist.org/packages/saschaende/laravel-hookable)
4
4
5
-
Laravel Hookable is a package that allows you to easily add hooks (actions and filters) to your Laravel applications,
6
-
similar to the hook system in WordPress.
5
+
Laravel Hookable is a package that allows you to use hooks (actions and filters) in Laravel applications – similar to the hook system in WordPress.
7
6
8
7
## Installation
9
8
@@ -13,59 +12,73 @@ You can install the package via Composer:
13
12
composer require saschaende/laravel-hookable
14
13
```
15
14
16
-
## Usage
15
+
The package is automatically registered by Laravel (see `composer.json`).
16
+
17
+
## How it works
17
18
18
-
### Adding Hooks
19
+
-**Actions**: Execute code without modifying data (e.g., for events or extensions).
20
+
-**Filters**: Allow modification of data.
19
21
20
-
You can add hooks using the `Hookable` facade. There are two types of hooks: actions and filters.
22
+
The package provides a `Hookable` facade that exposes the main methods. The binding is handled automatically via the ServiceProvider.
21
23
22
-
#### Actions
24
+
##Usage
23
25
24
-
Actions are hooks that do not modify data. You can add an action like this:
26
+
### Adding actions
25
27
26
28
```php
27
29
use SaschaEnde\Hookable\Facades\Hookable;
30
+
28
31
Hookable::action('my_action', function ($arg1, $arg2) {
29
32
// Do something with $arg1 and $arg2
30
33
});
31
34
```
32
35
33
-
You can then trigger the action like this:
36
+
To execute the action (e.g., at a specific point in your code):
0 commit comments