public function testExecuteListsCommandsWithNamespaceArgument() { require_once realpath(__DIR__ . '/../Fixtures/FooCommand.php'); $application = new Application(); $application->add(new \FooCommand()); $commandTester = new CommandTester($command = $application->get('list')); $parsedCommand = $commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true)); /** @var $parsedCommand ParsedCommand */ $injector = new \Auryn\Provider(); $injector->execute($parsedCommand->getCallable()); $output = <<<EOF foo:bar The foo:bar command EOF; $this->assertEquals($output, $commandTester->getDisplay(true)); }
<?php require __DIR__ . '/../vendor/autoload.php'; \ImagickDemo\Imagick\functions::load(); \ImagickDemo\ImagickDraw\functions::load(); \ImagickDemo\ImagickPixel\functions::load(); \ImagickDemo\ImagickPixelIterator\functions::load(); \ImagickDemo\Tutorial\functions::load(); $examples = (require_once "../imagick/test.data.php"); foreach ($examples as $example) { set_time_limit(30); list($function, $params) = $example; $injector = new Auryn\Provider(); $lowried = []; foreach ($params as $key => $value) { $lowried[':' . $key] = $value; } try { echo "function {$function} \n"; ob_start(); $injector->execute($function, $lowried); $contents = ob_get_contents(); ob_end_clean(); $filename = str_replace('\\', '_', $function); $paramString = ''; foreach ($params as $key => $value) { $paramString = md5($paramString . $key); $paramString = md5($paramString . $value); } global $imageType; $extension = $imageType;
<?php $injector = new \Auryn\Provider(); $injector->alias('Http\\Response', 'Http\\HttpResponse'); $injector->share('Http\\HttpRequest'); $injector->define('Http\\HttpRequest', [':get' => $_GET, ':post' => $_POST, ':cookies' => $_COOKIE, ':files' => $_FILES, ':server' => $_SERVER]); $injector->alias('Http\\Request', 'Http\\HttpRequest'); $injector->share('Http\\HttpResponse'); $injector->define('Mustache_Engine', [':options' => ['loader' => new Mustache_Loader_FilesystemLoader(dirname(__DIR__) . '/templates', ['extension' => '.html'])]]); $injector->delegate('Twig_Environment', function () use($injector) { $loader = new Twig_Loader_Filesystem(dirname(__DIR__) . '/templates'); $twig = new Twig_Environment($loader); return $twig; }); $injector->alias('Example\\Template\\Renderer', 'Example\\Template\\TwigRenderer'); $injector->alias('Example\\Template\\FrontendRenderer', 'Example\\Template\\FrontendTwigRenderer'); $injector->define('Example\\Page\\FilePageReader', [':pageFolder' => __DIR__ . '/../pages']); $injector->alias('Example\\Page\\PageReader', 'Example\\Page\\FilePageReader'); $injector->share('Example\\Page\\FilePageReader'); $injector->alias('Example\\Menu\\MenuReader', 'Example\\Menu\\ArrayMenuReader'); $injector->share('Example\\Menu\\FileMenuReader'); return $injector;
function lowrey($params) { $newParams = []; foreach ($params as $key => $value) { $newParams[':' . $key] = $value; } return $newParams; } $console = new Application(); $console->add(new AboutCommand()); $uploadCommand = new Command('upload', 'uploadFile'); $uploadCommand->addArgument('filename', InputArgument::REQUIRED, 'The name of the file to upload'); $uploadCommand->addOption('dir', null, InputArgument::OPTIONAL, 'Which directory to upload from', './'); $console->add($uploadCommand); $helloWorldCallable = function ($name) { echo "Hello world, and particularly {$name}" . PHP_EOL; }; $callableCommand = new Command('greet', $helloWorldCallable); $callableCommand->addArgument('name', InputArgument::REQUIRED, 'The name of the person to say hello to.'); $callableCommand->setDescription("Says hello to the world and one named person"); $console->add($callableCommand); try { $parsedCommand = $console->parseCommandLine(); } catch (\Exception $e) { $output = new BufferedOutput(); $console->renderException($e, $output); echo $output->fetch(); exit(-1); } $provider = new Auryn\Provider(); $provider->execute($parsedCommand->getCallable(), lowrey($parsedCommand->getParams()));
<?php chdir(dirname(__DIR__)); if (php_sapi_name() === 'cli-server' && is_file(dirname(__FILE__) . $_SERVER['REQUEST_URI'])) { return false; } # setup autoloading require 'vendor/autoload.php'; # load configs $config = array_replace_recursive(require 'config-defaults.php', file_exists('config.php') ? require 'config.php' : array()); # wireup dependencies $injector = new Auryn\Provider(); foreach ($config['definitions'] as $className => $params) { $injector->define($className, $params); } # initialize locale // putenv('LC_ALL=' . $config['ui']['locale']); // setlocale(LC_ALL, $config['ui']['locale']); // bindtextdomain('messages', 'locales'); // textdomain('messages'); # handle request \Http\Resource::handle($config['resources'], array($injector, 'make'));