diff --git a/.env.example.php b/.env.example.php new file mode 100644 index 00000000..6b3e9c98 --- /dev/null +++ b/.env.example.php @@ -0,0 +1,9 @@ + 'mysql', + 'DB_HOST' => 'localhost', + 'DB_DATABASE' => 'cachet', + 'DB_USERNAME' => 'homestead', + 'DB_PASSWORD' => 'secret', +]; diff --git a/.gitignore b/.gitignore index 290dae62..23dc9251 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ .env.php config.codekit !.env.heroku.php +!.env.example.php # Assets development /node_modules diff --git a/app/config/app.php b/app/config/app.php index 15f6db4b..db422d9c 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -127,6 +127,7 @@ return [ 'CachetHQ\Cachet\Providers\RepositoryServiceProvider', 'CachetHQ\Cachet\Providers\RoutingServiceProvider', + 'CachetHQ\Cachet\Providers\ConsoleServiceProvider', ], diff --git a/app/start/artisan.php b/app/start/artisan.php deleted file mode 100644 index 409e9adb..00000000 --- a/app/start/artisan.php +++ /dev/null @@ -1,12 +0,0 @@ -migrate = $migrate; + + parent::__construct(); + } + + /** + * Execute the console command. + * + * @return int|null + */ + public function fire() + { + if ($this->migrate) { + return $this->runMigrations(); + } + + $this->info('Please run "php artisan migrate" to finish the installation.'); + } + + /** + * Run the migrations. + * + * @return int|null + */ + protected function runMigrations() + { + $options = [ + '--database' => $this->input->getOption('database'), + '--force' => $this->input->getOption('force'), + '--seed' => $this->input->getOption('seed'), + ]; + + return $this->call('migrate', $options); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], + ]; + } +} diff --git a/src/Providers/ConsoleServiceProvider.php b/src/Providers/ConsoleServiceProvider.php new file mode 100644 index 00000000..368c78a1 --- /dev/null +++ b/src/Providers/ConsoleServiceProvider.php @@ -0,0 +1,31 @@ +commands('CachetHQ\Cachet\Commands\OneClickDeployCommand'); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $this->app->singleton('CachetHQ\Cachet\Commands\OneClickDeployCommand', function ($app) { + return new OneClickDeployCommand($app->environment('heroku')); + }); + } +} diff --git a/src/Providers/RepositoryServiceProvider.php b/src/Providers/RepositoryServiceProvider.php index 89166bd0..c24cba99 100644 --- a/src/Providers/RepositoryServiceProvider.php +++ b/src/Providers/RepositoryServiceProvider.php @@ -6,6 +6,21 @@ use Illuminate\Support\ServiceProvider; class RepositoryServiceProvider extends ServiceProvider { + /** + * Boot the service provider. + * + * @return void + */ + public function boot() + { + // + } + + /** + * Register the service provider. + * + * @return void + */ public function register() { $this->app->bind( diff --git a/src/Providers/RoutingServiceProvider.php b/src/Providers/RoutingServiceProvider.php index 07fc0f99..97011fd3 100644 --- a/src/Providers/RoutingServiceProvider.php +++ b/src/Providers/RoutingServiceProvider.php @@ -3,38 +3,30 @@ namespace CachetHQ\Cachet\Providers; use Illuminate\Support\ServiceProvider; -use RecursiveDirectoryIterator; class RoutingServiceProvider extends ServiceProvider { + /** + * Boot the service provider. + * + * @return void + */ + public function boot() + { + $files = glob(app_path('routes').'/*.php'); + + foreach ($files as $file) { + require $file; + } + } + + /** + * Register the service provider. + * + * @return void + */ public function register() { // } - - public function boot() - { - $this->routesInDirectory(); - } - - /** - * Organise Routes. - * - * @param string $app - */ - private function routesInDirectory($app = '') - { - $routeDir = app_path('routes/'.$app.($app !== '' ? '/' : null)); - - $iterator = new RecursiveDirectoryIterator($routeDir); - $iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS); - - foreach ($iterator as $route) { - $isDotFile = strpos($route->getFilename(), '.') === 0; - - if (!$isDotFile && !$route->isDir()) { - require $routeDir.$route->getFilename(); - } - } - } }