Skip to content

Latest commit

 

History

History
65 lines (56 loc) · 1.32 KB

README.md

File metadata and controls

65 lines (56 loc) · 1.32 KB

php-command-handler

travis_ci

Install from composer:

composer require zhikiri/command-handler

Usage example here:

$handler = new Handler();
$handler->group('main/', function () 
{
    $this->add('command, function ()
    {
        // some stuff here
    });
});

This initialization make available action path: main/command Notice: Sub groups also available

Initialize commands group with some middleware actions:

$handler = new Handler();
$handler->middleware(
    [
        function () {
            // middleware will execute before command
        },
    ],
    function () {
        // group and command initialization here
    },
    [
        function () {
            // middleware will execute after command
        },
    ],
);

Add new middleware:

$middleware = new Middleware();
$middleware->your_middleware = function () {
    // your middleware action code here
};

$handler = new Handler();
$handler->middleware(
    [
        $middleware->your_middleware
    ],
    function () {
        
        $this-add('command', function () 
        {
            // this action will execute after middleware `your_middleware`
        });
        
    },
    []
);