PHPackages                             foolz/plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. foolz/plugin

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

foolz/plugin
============

A plugin system for PHP, with cascading events.

1.0.0(12y ago)532.1k15[2 issues](https://github.com/FoolCode/Plugin/issues)1Apache-2.0PHPPHP &gt;=5.4.0

Since Apr 28Pushed 9y ago10 watchersCompare

[ Source](https://github.com/FoolCode/Plugin)[ Packagist](https://packagist.org/packages/foolz/plugin)[ Docs](http://www.foolz.us)[ RSS](/packages/foolz-plugin/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (4)Used By (1)

Foolz PHP Plugin system
=======================

[](#foolz-php-plugin-system)

A very complete plugin system to let you claim that your application supports plugins!

You will need PHP 5.4 for this to work. You can install it through [Composer](http://getcomposer.org/) and [Packagist](https://packagist.org/packages/foolz/plugin).

[![Build Status](https://camo.githubusercontent.com/d09014360db3aad68c9d986c838aa5e1418c49a767db6c70bcc8733f84dc0540/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f466f6f6c52756c657a2f506c7567696e2e706e67)](http://travis-ci.org/FoolRulez/Plugin)

Components
----------

[](#components)

- **Hooks**

    Place them in your code to execute events. Unlike several other packages, these Hooks allow interacting with the data and can hold the scope of the class.
- **Events**

    The events happen when a Hook with the same key is encountered. Events accept static methods and Closures, as well as a priority, because *you can stack them and have them passing variables to each other*.
- **Result**

    The object that Hooks and Events share, and return. They keep your code clean from mysterious function parameters and even more confusing return values.
- **Plugin**

    The internal package handler. *Plugins are actually Composer packages.* Use the bootstrap file to create new events and use the install/uninstall/upgrade hooks.
- **Loader**

    The packages utility. It looks into the folders you tell it to, finds plugins, loads them and give you the arrays.
- **PlugSuit** (trait)

    Add plugins automatically to your classes. It adds a before and after hook, and lets you override the parameters passed to the methods.

What will you have to do? You must use the Loader class to create your own administration panel and run the plugins you choose to run. Since it doesn't have any database bind (or any dependency at all), you must create an enabled/disabled system yourself.

Some examples follow.

You can go in-depth with these explanations with the following pages:

- [Hooks, Events and Results](hooks_events_results.md)
- [Plugin packages](plugin_packages.md)

Hooks and Events
----------------

[](#hooks-and-events)

The most basic part of the package. You can use Hook and Event anywhere in your code, not only in the plugins.

```
