Download the PHP package slaxweb/hooks without Composer

On this page you can find all versions of the php package slaxweb/hooks. 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 hooks

Hooks

Build Status

Hooks component for the SlaxWeb/Framework, to execute arbitrary code in regular application execution. Even when the component is meant for the SlaxWeb/Framework it can be used outside of it as well. It the SlaxWeb/Logger as an additional component.

For ease of use the component provides a Factory and a Service Provider for the Pimple/Container.

Installation

Easiest form of installation is through composer, edit your composer.json file to contain:

Usage

This section will cover instantiation of the Hooks container, and adding simple hook definitions to the container, as well as execution of this definition, and advanced execution of hook definitions.

Instantiation

You do not need to instantiate the Logger component it self, but you do have to instantiate the Config component, and make sure that the logger configuration is loaded, refer to Logger documentation on how to get this done.

When you got the dependencies instantiated the usage is pretty straight forward:

You can achieve the same thing using the Pimple Dependency Injection Container, just make sure that you have registered the Service Providers of all 3 components:

When you have all those three providers registered, you can safely use the hooks container:

Multiple Hook Definitions

As it is already visible from above examples, hook execution method will return the value of the hook definition. But a single hook point may hold more than one definition. In this case the exec method will return all return values in an array, except if the return value of definition was null. If no definition returned a valid return value, the exec method will return an empty array.

For a better representation of the above examples, please refer to the code example bellow:

Definition Execution Interruption

Additionally to multiple definitions per hook, a hook can also prevent other definitions from executing. For this case an instance of the container is passed into the hook definition as the first parameter. Each hook may call stopExec method on that passed in container object, and it will stop execution of other hook definitions.

Hook definition parameters

When calling the exec method you can pass additional parameters to it, and all those parameters will be passed on to your hook definition.


All versions of hooks with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
slaxweb/logger Version ~0.5
slaxweb/getset Version ~0.1
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 slaxweb/hooks contains the following files

Loading the files please wait ....