From 8b054c3aa6c0bbe932d7969400c8263f0dfe5c69 Mon Sep 17 00:00:00 2001 From: Joe Wallace Date: Tue, 15 Jan 2013 20:57:07 -0600 Subject: [PATCH] Initial commit --- .gitignore | 4 + .travis.yml | 11 ++ composer.json | 27 ++++ phpunit.xml | 18 +++ src/Joecwallace/Artisan/ArtisanRunner.php | 28 ++++ .../Artisan/ArtisanWebServiceProvider.php | 46 +++++++ src/Joecwallace/Artisan/HtmlOutput.php | 126 ++++++++++++++++++ src/Joecwallace/Artisan/routes.php | 15 +++ src/config/config.php | 7 + tests/.gitkeep | 0 10 files changed, 282 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 composer.json create mode 100644 phpunit.xml create mode 100644 src/Joecwallace/Artisan/ArtisanRunner.php create mode 100644 src/Joecwallace/Artisan/ArtisanWebServiceProvider.php create mode 100644 src/Joecwallace/Artisan/HtmlOutput.php create mode 100644 src/Joecwallace/Artisan/routes.php create mode 100644 src/config/config.php create mode 100644 tests/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2c1fc0c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/vendor +composer.phar +composer.lock +.DS_Store \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0edb59c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: php + +php: + - 5.3 + - 5.4 + +before_script: + - curl -s http://getcomposer.org/installer | php + - php composer.phar install --dev + +script: phpunit \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..78c5b0f --- /dev/null +++ b/composer.json @@ -0,0 +1,27 @@ +{ + "name": "joecwallace/artisan", + "description": "A web interface for the Laravel Artisan CLI", + "keywords": [ "laravel", "artisan" ], + "license": "MIT", + "authors": [ + { + "name": "Joe Wallace", + "email": "joe.c.wallace@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/support": "4.0.x" + }, + "autoload": { + "psr-0": { + "Joecwallace\\Artisan": "src/" + } + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..8425e15 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,18 @@ + + + + + ./tests/ + + + \ No newline at end of file diff --git a/src/Joecwallace/Artisan/ArtisanRunner.php b/src/Joecwallace/Artisan/ArtisanRunner.php new file mode 100644 index 0000000..9087217 --- /dev/null +++ b/src/Joecwallace/Artisan/ArtisanRunner.php @@ -0,0 +1,28 @@ +getLoadedProviders(); + + foreach (Config::get('app.providers') as $provider) + { + if ( ! isset($providers[$provider])) + { + $app->register(new $provider($app)); + } + } + + $_SERVER['argv'] = $args; + $output = new HtmlOutput; + + Application::start($app)->run(null, $output); + } +} \ No newline at end of file diff --git a/src/Joecwallace/Artisan/ArtisanWebServiceProvider.php b/src/Joecwallace/Artisan/ArtisanWebServiceProvider.php new file mode 100644 index 0000000..d2347c3 --- /dev/null +++ b/src/Joecwallace/Artisan/ArtisanWebServiceProvider.php @@ -0,0 +1,46 @@ +package('joecwallace/artisan'); + + include __DIR__.'/routes.php'; + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + // + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } + +} \ No newline at end of file diff --git a/src/Joecwallace/Artisan/HtmlOutput.php b/src/Joecwallace/Artisan/HtmlOutput.php new file mode 100644 index 0000000..fc1ba68 --- /dev/null +++ b/src/Joecwallace/Artisan/HtmlOutput.php @@ -0,0 +1,126 @@ +', $message); + } + + /** + * Writes a message to the output. + * + * @param string|array $messages The message as an array of lines of a single string + * @param Boolean $newline Whether to add a newline or not + * @param integer $type The type of output (0: normal, 1: raw, 2: plain) + * + * @throws \InvalidArgumentException When unknown output type is given + * + * @api + */ + public function write($messages, $newline = false, $type = 0) + { + $messages = (array)$messages; + + foreach ($messages as $message) + { + echo $this->formatOutput($message); + } + + if ($newline) echo '
'; + } + + /** + * Writes a message to the output and adds a newline at the end. + * + * @param string|array $messages The message as an array of lines of a single string + * @param integer $type The type of output (0: normal, 1: raw, 2: plain) + * + * @api + */ + public function writeln($messages, $type = 0) + { + $this->write($messages, true, $type); + } + + /** + * Sets the verbosity of the output. + * + * @param integer $level The level of verbosity + * + * @api + */ + public function setVerbosity($level) + { + $this->verbosity = $level; + } + + /** + * Gets the current verbosity of the output. + * + * @return integer The current level of verbosity + * + * @api + */ + public function getVerbosity() + { + return $this->verbosity; + } + + /** + * Sets the decorated flag. + * + * @param Boolean $decorated Whether to decorate the messages or not + * + * @api + */ + public function setDecorated($decorated) + { + $this->decorated = $decorated; + } + + /** + * Gets the decorated flag. + * + * @return Boolean true if the output will decorate messages, false otherwise + * + * @api + */ + public function isDecorated() + { + return $this->decorated; + } + + /** + * Sets output formatter. + * + * @param OutputFormatterInterface $formatter + * + * @api + */ + public function setFormatter(OutputFormatterInterface $formatter) + { + $this->formatter = $formatter; + } + + /** + * Returns current output formatter instance. + * + * @return OutputFormatterInterface + * + * @api + */ + public function getFormatter() + { + return $this->formatter; + } + +} \ No newline at end of file diff --git a/src/Joecwallace/Artisan/routes.php b/src/Joecwallace/Artisan/routes.php new file mode 100644 index 0000000..8cbba96 --- /dev/null +++ b/src/Joecwallace/Artisan/routes.php @@ -0,0 +1,15 @@ +where('uri', '^($|\/.*)'); \ No newline at end of file diff --git a/src/config/config.php b/src/config/config.php new file mode 100644 index 0000000..de90831 --- /dev/null +++ b/src/config/config.php @@ -0,0 +1,7 @@ + 'artisan', + +); \ No newline at end of file diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29