Download the PHP package tonini46/laravel-hooks-plus without Composer

On this page you can find all versions of the php package tonini46/laravel-hooks-plus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-hooks-plus

Laravel Hooks Plus

The WordPress filters, actions system in Laravel.

About

Read more about filters and actions

Hooks are a way for one piece of code to interact/modify another piece of code at specific, pre-defined spots.

Installation

DONE! Now you can use laravel-hooks

Functions

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.

Parameters

Actions are the hooks that the Laravel application launches at specific points during execution, or when specific events occur.

Parameters

This function invokes all functions attached to filter hook $tag. It is possible to create new filter hooks by simply calling this function, specifying the name of the new hook using the $tag parameter.

Parameters

Filter hooks to allow modify various types of internal data at runtime.

Parameters

How to pass callback function?

The callback function could be a string referring to a class in the application MyNamespace\Http\Listener@myHookListener, an array callback [$object, 'method'] or a globally registered function global_function, anonymous function.

Example using anonymous function:

Example using referring to a class's method:

Example using array callback:

Usage

Actions

Wherever you want, you can create a new action in you Laravel application:

Here, user_created is the name of the action, which will use later when the action will be listening. And $user is the parameters, which will be found whenever you listen the action. These can be anything.

To listen to your actions, you attach listeners. These are best added to your AppServiceProvider boot() method.

For example if you wanted to hook in to the above hook, you could do:

The first argument must be the name of the action. The second would be a closures, callbacks and anonymous functions. The third specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. Default value: 10. And fourth, the number of arguments the function accepts. Default value: 1

Filters

Filters always have to have data coming in and data going out to ensure the data is output in the browser (your content may be passed through other filters before getting output in the browser). By comparison, actions, which are similar to filters, do not require that anything to be returned, although data can be returned through actions as well.

Basically, filters are functions that can be used in Laravel application to pass data through. They allows developers to modify the default behavior of a specific function.

Here's an example of how filter used in a real application.

Post.php is a model or class , where it builds a query to fetch all published posts

Using filter we can modify this query:

Now, in the entry point of application like any module or plugin's you can modify this post published query.

In Module's or Plugin's service provider (preferably in the boot method) we'll add a listener for the filter.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-hooks-plus with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3|^8.0
laravel/framework Version ^5.7|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tonini46/laravel-hooks-plus contains the following files

Loading the files please wait ....