Download the PHP package shohel/pluggable without Composer
On this page you can find all versions of the php package shohel/pluggable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shohel/pluggable
More information about shohel/pluggable
Files in shohel/pluggable
Package pluggable
Short Description Enable action/filter hook to make your PHP project extendable
License MIT
Informations about the package pluggable
If you like this library, place star ⭐ at this repository and my profile please.
Pluggable
With Pluggable, you can register your actions hooks filter hooks to your PHP Project like WordPress, no matter it's raw PHP project / Laravel / Codeigniter / Moodle LMS / or any others. This is a library that allows you to make your PHP project so extensible.
Installation
Use [Composer] to install the package:
Integration in Laravel
Pluggable has great support for Laravel and comes with a Service Provider for easy integration. The vendor/autoload.php is included by Laravel, so you don't have to require or autoload manually. Just see the instructions below.
After you have installed Pluggable, open your Laravel config file config/app.php
and add the following lines.
In the $providers array add the service providers for this package as the very first item.
Now the Pluggable will be auto-loaded by Laravel.
Integration in Any other PHP Project
Include composer autoload file to your project before bootsrap / entry point.
Pluggable will do the rest.
Usage
Action Hook
do_action( string $tag, mixed $arg )
Execute functions hooked on a specific action hook.
This function invokes all functions attached to action hook $tag. It is possible to create new action hooks by simply calling this function, specifying the name of the new hook using the $tag parameter.
Example usage:
Flter Hook
apply_filters( string $tag, mixed $value )
Calls the callback functions that have been added to a filter hook.
The callback functions attached to the filter hook are invoked by calling this function. This function can be used to create a new filter hook by simply calling this function with the name of the new hook specified using the $tag parameter.
Example usage:
Hooks call back from the class
You can reference a class method to hooks callback instead of function, use ['className','callbackMethod']
or use it within a class. [$this,'getStuffDone']
Here is a better way of doing it:
As the hooks will work exactly like WordPress, you can read more about action hooks / filter hooks to WordPress.org documentation.
If you like this library, place star ⭐ at this repository and my profile please.