示例#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
#!/usr/bin/env php
<?php 
use Ballen\Clip\Exceptions\CommandNotFoundException;
use Ballen\Clip\Utilities\CommandRouter;
/**
 * SpringoHQ Agent
 *
 * @link http://springohq.com
 * @link https://github.com/springohq/agent
 * @license http://opensource.org/licenses/GPL-2.0
 *
 */
require_once 'vendor/autoload.php';
$app = new CommandRouter($argv);
// update
$app->add('update', Springohq\Agent\Commands\UpdateHandler::class);
// register-server
$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');
示例#3
0
 * @author Bobby Allen <*****@*****.**>
 * @license https://raw.githubusercontent.com/bobsta63/clip/master/LICENSE
 * @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?