Ayuco
Command-line interface for the Wordpress-MVC framework., (*1)
Ayuco works outside this framework aswell, and can be used to execute command written in PHP., (*2)
Usage
use Ayuco\Listener;
Create a listener variable:, (*3)
$ayuco = new Listener();
// or without initial use
$ayuco = new Ayuco\Listener()
Register your commands., (*4)
$ayuco->register($command1)
->register($command2);
Start interpreting or listening:, (*5)
$ayuco->interpret();
Use in command line:, (*6)
php filename command_key arguments
If filename
is ayuco.php
and command_key
is clear_cache
, command will be:, (*7)
php ayuco.php clear_cache
Create a custom command
Create your own class command by extending from Ayuco base command class:, (*8)
use Ayuco\Command;
class MyCommand extends Command
{
protected $key = 'command_key';
public function call($args = [])
{
// TODO command action.
}
}
Example for a clear cache command., (*9)
use Ayuco\Command;
class ClearCacheCommand extends Command
{
protected $key = 'clear_cache';
public function call($args = [])
{
Cache::flush(); // Example
}
}
Registration in listener would be:, (*10)
$ayuco->register(new ClearCacheCommand);
Requirements
Coding guidelines
PSR-4., (*11)
LICENSE
The MIT License (MIT), (*12)
Copyright (c) 2016 10Quality - http://www.10quality.com, (*13)