Download the PHP package gburtini/hooks without Composer

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

PHP Hooks and Filters System

Event-driven programming, a plugin architecture, hooks, filters, all wrapped in to a simple, efficient and clean Composer-ready interface.

This is an elegant way of coding plugin architectures or other decoupled software solutions. The class provides three major methods: bind, run and filter; combined, these allow you to integrate in to existing systems without interfering with their existing code.

There's also a plugin loader in Plugins.php which can be used to load a directory of optional code. Use is simple: Plugins::load("directory") will traverse the directory and load all non-disabled (~, . prefix) folders containing a init.php file.

Installation

Everything you need is contained within the single file Hooks.php, but the most convenient way to install is with composer:

composer require gburtini/hooks

Usage

The designed use case is that throughout your existing software, you will call Hooks::filter and Hooks::run where you want to allow users to hook with a specified $hook value. Then users can call Hooks::bind() anytime before your code runs to associate code with the various locations -- filters will return the value (so that a function can change it) and run calls will simply run functions with no in-code side effects.

Debugging

The Hooks class has a debug level setting which produces some output indicating which hooks are running and when. Call Hooks::setDebugLevel($debug_level) at runtime to set the debug output. $debug_level can take on the following values:

You can also combine these with the bitwise OR, for example Hooks::DEBUG_EVENTS | Hooks::DEBUG_BINDS outputs all the run/filter/bind calls as they happen.

Future Work

A nice future feature would be to enforce some sort of constraints on what these binds can do -- allowing "untrusted" (in the sense of the data) code to run in some sort of quasi-sandbox; for example, the filters could check to ensure the value was constrained to a particular type, range or callback validation.

Timing functionality for the debug code to see which hooks and associated callbacks are slow is an interesting angle here too.

Sorting can be called less frequently. If nothing has changed, it is unnecessary to call the sort function again. That said, the used quicksort variant should be rapid on already sorted data.

License

Copyright (C) 2012-2015 Giuseppe Burtini

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.


All versions of hooks with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.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 gburtini/hooks contains the following files

Loading the files please wait ....