Download the PHP package bainternet/php-hooks without Composer

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

PHP-Hooks

The PHP Hooks Class is a fork of the WordPress filters hook system rolled in to a class to be ported into any php based system

Head Over to http://bainternet.github.io/PHP-Hooks/ For more info


How to Use?

Simple, Include the class file in your application bootstrap (setup/load/configuration or whatever you call it) and start hooking your filter and action hooks using the global $hooks. Ex:

then all that is left for you is to call the hooked function when you want anywhere in your aplication, EX:

and you output will be:

Methods

ACTIONS:

add_action Hooks a function on to a specific action.

 - @access public
 - @since 0.1
 - @param string $tag The name of the action to which the $function_to_add is hooked.
 - @param callback $function_to_add The name of the function you wish to be called.
 - @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). 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.
 - @param int $accepted_args optional. The number of arguments the function accept (default 1).

do_action Execute functions hooked on a specific action hook.

 - @access public
 - @since 0.1
 - @param string $tag The name of the action to be executed.
 - @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action.
 - @return null Will return null if $tag does not exist

remove_action Removes a function from a specified action hook.

 - @access public
 - @since 0.1
 - @param string $tag The action hook to which the function to be removed is hooked.
 - @param callback $function_to_remove The name of the function which should be removed.
 - @param int $priority optional The priority of the function (default: 10).
 - @return boolean Whether the function is removed.

has_action Check if any action has been registered for a hook.

 -  @access public
 -  @since 0.1
 -  @param string $tag The name of the action hook.
 -  @param callback $function_to_check optional.
 -  @return mixed If $function_to_check is omitted, returns boolean for whether the hook has anything registered.
  When checking a specific function, the priority of that hook is returned, or false if the function is not attached.
  When using the $function_to_check argument, this function may return a non-boolean value that evaluates to false (e.g.) 0, so use the === operator for testing the return value.

did_action Retrieve the number of times an action is fired.

 -  @access public
 -  @since 0.1
 -  @param string $tag The name of the action hook.
 -  @return int The number of times action hook <tt>$tag</tt> is fired

FILTERS:

add_filter Hooks a function or method to a specific filter action.

 - @access public
 -  @since 0.1
 -  @param string $tag The name of the filter to hook the $function_to_add to.
 -  @param callback $function_to_add The name of the function to be called when the filter is applied.
 -  @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). 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.
 -  @param int $accepted_args optional. The number of arguments the function accept (default 1).
 -  @return boolean true

remove_filter Removes a function from a specified filter hook.

 -  @access public
 -  @since 0.1
 -  @param string $tag The filter hook to which the function to be removed is hooked.
 -  @param callback $function_to_remove The name of the function which should be removed.
 -  @param int $priority optional. The priority of the function (default: 10).
 -  @param int $accepted_args optional. The number of arguments the function accepts (default: 1).
 -  @return boolean Whether the function existed before it was removed.

has_filter Check if any filter has been registered for a hook.

 -   @access public
 -   @since 0.1
 -   @param string $tag The name of the filter hook.
 -   @param callback $function_to_check optional.
 -   @return mixed If $function_to_check is omitted, returns boolean for whether the hook has anything registered.
   When checking a specific function, the priority of that hook is  returned, or false if the function is not attached.
   When using the $function_to_check argument, this function may return a non-boolean value that evaluates to false (e.g.) 0, so use the === operator for testing the return value.

apply_filters Call the functions added to a filter hook.

 -  @access public
 -  @since 0.1
 -  @param string $tag The name of the filter hook.
 -  @param mixed $value The value on which the filters hooked to <tt>$tag</tt> are applied on.
 -  @param mixed $var,... Additional variables passed to the functions hooked to <tt>$tag</tt>.
 -  @return mixed The filtered value after all hooked functions are applied to it.

There are a few more methods but these are the main Ones you'll use :).

Download

You can download this project in either zip or tar formats

You can also clone the project with Git by running:

$ git clone git://github.com/bainternet/PHP-Hooks.git

License

Since this class is derived from the WordPress Plugin API so are the license and they are GPL http://www.gnu.org/licenses/gpl.html

Analytics


All versions of php-hooks with dependencies

PHP Build Version
Package Version
No informations.
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 bainternet/php-hooks contains the following files

Loading the files please wait ....