Download the PHP package jrbarnard/hookable without Composer

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

Hookable

Build Status StyleCI

Hookable is a trait that can be used by any PHP class, it's purpose is to provide a simple API for creating hookable 'points' within your methods and allowing you to 'hook' into those points when using the class externally or from an extending child.

The purpose for this is to be able to quickly add event like functionality during code execution with a very flexible API.

E.g:

Contents

  1. Requirements
  2. Installation
  3. Usage
  4. Contributing
  5. License

Requirements

Hookables minimum PHP requirement is 5.6, this is because of it's use of variadic functions. Beyond that, there shouldn't be any other requirements, if you find any, please log as a ticket / do a pull request.

Currently HHVM / Hack is not supported.

Installation

Composer is the recommended installation method:

However you can also download this repo, unzip it and include it in your project.

Usage

Registering and running hooks

One of the main use cases for this Trait is when you have a very generic abstract / parent class that is extended a lot, and sometimes you want to override / run actions based on the generic methods, without overriding the whole method.

An example of this is below:

You can also register hooks externally to the object:

You don't need to pass a closure directly, you can also reference a specific function or class method using array syntax:

All parameters passed when running a hook are passed by reference by default, this allows us to (if we want to alter passed parameters that aren't objects):

You can use any number of parameters you want with runHook and they will be unpacked and available as parameters on the callbacks you specify with registerHook.

Priorities

Hookable also has priorities built in, when you register a hook you can pass a third parameter after the callback which will be the priority of the callback, this defines where it's added in the calling order, the higher the number the later in the calling order it's run:

If you set two hooks with the same key and the same priority, it will use when they were registered as the order, it won't override the already set one.

Checking and removing hooks

You can check to see if a hook exists by calling hasHook on the relevant hookable object:

If you want to remove hooks for an object you can do so with the clearHooks method:

Contributing

Please look at the contributing file

License

MIT License


All versions of hookable with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.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 jrbarnard/hookable contains the following files

Loading the files please wait ....