示例#1
0
 public function testCallingInvalidHandlerClassNotImplementingConsoleInterface()
 {
     $command_name = 'test';
     $app = new CommandRouter($this->argv_example1);
     $app->add($command_name, 'TestInvalidHandler');
     $this->setExpectedException('\\InvalidArgumentException', 'The command class must implement the "CommandInterface" interface.');
     $app->dispatch($command_name);
 }
示例#2
0
$app->add('register-server', Springohq\Agent\Commands\RegisterServerHandler::class);
// reload --nginx --php-fpm
$app->add('reload', Springohq\Agent\Commands\ReloadServiceHandler::class);
// stats
$app->add('stats', Springohq\Agent\Commands\StatsHandler::class);
// site:create --domain=mydomain.com --aliases=www.mydomain.com,another.mydomain.com
$app->add('site:create', 'Springohq\\Agent\\Commands\\SiteHandler@createSite');
$app->add('site:destroy', 'Springohq\\Agent\\Commands\\SiteHandler@destroySite');
// scheduler:create --domain=mydomain.com --type=laravel
$app->add('scheduler:create', 'Springohq\\Agent\\Commands\\SchedulerHandler@createScheduler');
$app->add('scheduler:destroy', 'Springohq\\Agent\\Commands\\SchedulerHandler@destroyScheduler');
// envars mydomain.com --key=value --other=example
$app->add('envars:set', 'Springohq\\Agent\\Commands\\EnvarHandler@push');
$app->add('envars:patch', 'Springohq\\Agent\\Commands\\EnvarHandler@patch');
// lessl:create --domain=mydomain.com --email=joe@joebloggs.com --aliases=www.mydomain.com,another.mydomain.com
$app->add('lessl:create', 'Springohq\\Agent\\Commands\\SSLCertHandler@createLetsEncryptCert');
$app->add('lessl:destroy', 'Springohq\\Agent\\Commands\\SSLCertHandler@destroyLetsEncryptCert');
$app->add('lessl:renew', 'Springohq\\Agent\\Commands\\SSLCertHandler@renewLetsEncryptCert');
// httpredir::add --domain=mydomain.com --aliases=www.mydomain.com,another.mydomain.com
$app->add('httpredir:add', 'Springohq\\Agent\\Commands\\SiteHandler@addHttpRedirect');
$app->add('httpredir:remove', 'Springohq\\Agent\\Commands\\SiteHandler@removeHttpRedirection');
// database:create --database=
$app->add('database:create', 'Springohq\\Agent\\Commands\\DatabaseHandler@createDatabase');
$app->add('database:destroy', 'Springohq\\Agent\\Commands\\DatabaseHandler@destroyDatabase');
// Default handler registration.
$app->add('default', Springohq\Agent\Commands\DefaultHandler::class);
try {
    $app->dispatch();
} catch (CommandNotFoundException $exception) {
    $app->dispatch('default');
}
示例#3
0
 * @link https://github.com/bobsta63/clip
 * @link http://www.bobbyallen.me
 *
 */
$bindir = dirname(__FILE__);
// Initiate the Composer autoloader.
require_once $bindir . '/../vendor/autoload.php';
// If not using Composer in your project you'll need to "require" the command handlers..
require_once 'Commands/TestHandler.php';
require_once 'Commands/HelpHandler.php';
require_once 'Commands/UserHandler.php';
require_once 'Commands/FlagsHandler.php';
require_once 'Commands/RequiredOptionsExampleHander.php';
$app = new CommandRouter($argv);
// Add our command and their handler class mappings
$app->add('test', 'Commands\\TestHandler@displayTest');
// Registering commands using the "at" notation and specifying the class method.
$app->add('help', Commands\HelpHandler::class);
// Registering command using class name (string)
$app->add('check:name', ['Commands\\UserHandler', 'handle']);
// Registering the command handler using array notation.
$app->add('flags', 'Commands\\FlagsHandler.handle');
// Registering the command handler using "dot" notation.
$app->add('profile', Commands\RequiredOptionsExampleHander::class);
// An example of setting required options.
try {
    $app->dispatch();
} catch (CommandNotFoundException $exception) {
    // If the requested command is not found we'll display the 'help' text by default?
    $app->dispatch('help');
}