Download the PHP package sciactive/hookphp without Composer

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

HookPHP

Build Status Latest Stable Version License Open Issues Code Quality Coverage

Method hooking (decorators) in PHP.

Installation

You can install HookPHP with Composer.

Getting Started

If you don't use an autoloader, all you need to do is include the Hook.php file.

Now you can start setting up objects for method hooking.

And modifying their method calls.

And now calling a hooked method like this:

Will output this:

Adding a Callback with addCallback

A callback is called either before a method runs or after. The callback is passed an array of arguments or return value which it can freely manipulate. If the callback runs before the method and sets the arguments array to false (or causes an error), the method will not be run. Callbacks before a method are passed the arguments given when the method was called, while callbacks after a method are passed the return value (in an array) of that method.

The callback can receive up to 5 arguments, in this order:

A hook is the name of whatever method it should catch. A hook can also have an arbitrary name, but be wary that it may already exist and it may result in your callback being falsely called. In order to reduce the chance of this, always use namespaced names to begin arbitrary hook names. E.g. '\MyProject\PlayerBonus'.

If the hook is called explicitly, callbacks defined to run before the hook will run immediately followed by callbacks defined to run after.

A negative $order value means the callback will be run before the method, while a positive value means it will be run after. The smaller the order number, the sooner the callback will be run. You can think of the order value as a timeline of callbacks, zero (0) being the actual method being hooked.

Additional identical callbacks can be added in order to have a callback called multiple times for one hook.

The hook "all" is a pseudo hook which will run regardless of what was actually caught. Callbacks attached to the "all" hook will run before callbacks attached to the actual hook.

Note: Be careful to avoid recursive callbacks, as they may result in an infinite loop.

The parameters and return value for addCallback are:

Options for a Callback

A callback is passed the following parameters:

A callback can alter $arguments to alter what is given to or returned from the method call.

A callback can replace or alter $object to affect what the method is being called on.

A callback can replace $function to cause a different function or method to run instead.

A callback can add and alter data in the $data array to communicate with other callbacks. This is especially useful when communicating with callbacks that run on the other side of the method call.

Retrieving a Hooked Object

If you need to retrieve an object that has been hooked, you can use the _hookObject method:

Contacting the Developer

There are several ways to contact HookPHP's developer with your questions, concerns, comments, bug reports, or feature requests.


All versions of hookphp with dependencies

PHP Build Version
Package Version
Requires php Version ~7.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 sciactive/hookphp contains the following files

Loading the files please wait ....