Skip to content

Commit

Permalink
Large refactor of HTTP and Console stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 20, 2014
1 parent 834cb75 commit 4301348
Show file tree
Hide file tree
Showing 19 changed files with 179 additions and 356 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace App\Console;
<?php namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
Expand Down
41 changes: 41 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php namespace App\Console;

use Exception;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel {

/**
* The bootstrap classes for the application.
*
* @return void
*/
protected $bootstrappers = [
'Illuminate\Foundation\Bootstrap\LoadEnvironment',
'Illuminate\Foundation\Bootstrap\LoadConfiguration',
'Illuminate\Foundation\Bootstrap\RegisterProviders',
'Illuminate\Foundation\Bootstrap\BootProviders',
];

/**
* Run the console application.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int
*/
public function handle($input, $output = null)
{
try
{
return parent::handle($input, $output);
}
catch (Exception $e)
{
$output->writeln((string) $e);

return 1;
}
}

}
54 changes: 54 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php namespace App\Http;

use Exception;
use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel {

/**
* The bootstrap classes for the application.
*
* @return void
*/
protected $bootstrappers = [
'Illuminate\Foundation\Bootstrap\LoadEnvironment',
'Illuminate\Foundation\Bootstrap\HandleExceptions',
'Illuminate\Foundation\Bootstrap\LoadConfiguration',
'Illuminate\Foundation\Bootstrap\RegisterProviders',
'Illuminate\Foundation\Bootstrap\BootProviders',
];

/**
* The application's HTTP middleware stack.
*
* @var array
*/
protected $stack = [
'App\Http\Middleware\MaintenanceMiddleware',
'Illuminate\Cookie\Middleware\Guard',
'Illuminate\Cookie\Middleware\Queue',
'Illuminate\Session\Middleware\Reader',
'Illuminate\Session\Middleware\Writer',
'Illuminate\View\Middleware\ErrorBinder',
'App\Http\Middleware\CsrfMiddleware',
];

/**
* Handle an incoming HTTP request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function handle($request)
{
try
{
return parent::handle($request);
}
catch (Exception $e)
{
throw $e;
}
}

}
53 changes: 0 additions & 53 deletions app/Providers/AppServiceProvider.php

This file was deleted.

4 changes: 2 additions & 2 deletions app/Providers/ArtisanServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ArtisanServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->commands('App\Console\InspireCommand');
$this->commands('App\Console\Commands\InspireCommand');
}

/**
Expand All @@ -29,7 +29,7 @@ public function register()
*/
public function provides()
{
return ['App\Console\InspireCommand'];
return ['App\Console\Commands\InspireCommand'];
}

}
40 changes: 0 additions & 40 deletions app/Providers/ErrorServiceProvider.php

This file was deleted.

19 changes: 12 additions & 7 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@

class RouteServiceProvider extends ServiceProvider {

/**
* The root namespace to assume when generating URLs to actions.
*
* @var string
*/
protected $rootUrlNamespace = 'App\Http\Controllers';

/**
* The controllers to scan for route annotations.
*
Expand All @@ -23,6 +16,18 @@ class RouteServiceProvider extends ServiceProvider {
'App\Http\Controllers\Auth\PasswordController',
];

/**
* All of the application's route middleware keys.
*
* @var array
*/
protected $middleware = [
'auth' => 'App\Http\Middleware\AuthMiddleware',
'auth.basic' => 'App\Http\Middleware\BasicAuthMiddleware',
'csrf' => 'App\Http\Middleware\CsrfMiddleware',
'guest' => 'App\Http\Middleware\GuestMiddleware',
];

/**
* Called before routes are registered.
*
Expand Down
25 changes: 5 additions & 20 deletions artisan
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,7 @@ require __DIR__.'/bootstrap/autoload.php';
|
*/

$app = require_once __DIR__.'/bootstrap/start.php';

/*
|--------------------------------------------------------------------------
| Load The Artisan Console Application
|--------------------------------------------------------------------------
|
| We'll need to run the script to load and return the Artisan console
| application. We keep this in its own script so that we will load
| the console application independent of running commands which
| will allow us to fire commands from Routes when we want to.
|
*/

$app->setRequestForConsoleEnvironment();

$artisan = Illuminate\Console\Application::start($app);
$app = require_once __DIR__.'/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
Expand All @@ -56,7 +40,10 @@ $artisan = Illuminate\Console\Application::start($app);
|
*/

$status = $artisan->run();
$status = $app->make('Illuminate\Contracts\Console\Kernel')->handle(
new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);

/*
|--------------------------------------------------------------------------
Expand All @@ -69,6 +56,4 @@ $status = $artisan->run();
|
*/

$app->shutdown();

exit($status);
50 changes: 50 additions & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/

$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/..')
);

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/

$app->bind(
'Illuminate\Contracts\Http\Kernel',
'App\Http\Kernel'
);

$app->bind(
'Illuminate\Contracts\Console\Kernel',
'App\Console\Kernel'
);

/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/

return $app;
16 changes: 0 additions & 16 deletions bootstrap/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,3 @@
{
require $compiledPath;
}

/*
|--------------------------------------------------------------------------
| Register The Workbench Loaders
|--------------------------------------------------------------------------
|
| The Laravel workbench provides a convenient place to develop packages
| when working locally. However we will need to load in the Composer
| auto-load files for the packages so that these can be used here.
|
*/

if (is_dir($workbench = __DIR__.'/../workbench'))
{
Illuminate\Workbench\Starter::start($workbench);
}
Loading

0 comments on commit 4301348

Please sign in to comment.