jchook / tappable-php

A plugin framework for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tappable: a Plugin Framework for PHP

License MIT Test Coverage 100% PHP

Tappable helps you create modular PHP apps that accept plugins or "middleware".

Concepts

A Tappable app has plugins.

Plugins communicate via actions.

Every action passes through each plugin, sequentially.

Plugins can dispatch new actions, handle actions, keep state, or throw errors.

Each plugin wraps the next plugin. Plugins can wrap next() calls to perform "before" and "after" business logic, try/catch logic, modify actions, cancel actions, etc.

This design enables plugin authors to write modular functionality with versatile, statically-typed interoperability and powerful control flow.

Example Usage

The simple skeleton for a Tappable app looks like this.

<?php

class MyApp extends TappableBase {}

class MyPlugin extends TapBase {}

class MyAction extends ActionBase {}

$app = new MyApp();
$app->tap(new MyPlugin());
$app->dispatch(new MyAction());

?>

About

A plugin framework for PHP

License:MIT License


Languages

Language:PHP 99.3%Language:Shell 0.5%Language:Awk 0.2%