Browse Source

Add application stack to app server provider.

Taylor Otwell 10 years ago
parent
commit
2893433b35
1 changed files with 18 additions and 5 deletions
  1. 18 5
      app/Providers/AppServiceProvider.php

+ 18 - 5
app/Providers/AppServiceProvider.php

@@ -1,6 +1,8 @@
 <?php namespace App\Providers;
 
+use Illuminate\Routing\Router;
 use Illuminate\Support\ServiceProvider;
+use Illuminate\Routing\Stack\Builder as Stack;
 
 class AppServiceProvider extends ServiceProvider {
 
@@ -11,7 +13,22 @@ class AppServiceProvider extends ServiceProvider {
 	 */
 	public function boot()
 	{
-		//
+		// This service provider is a convenient place to register your services
+		// in the IoC container. If you wish, you may make additional methods
+		// or service providers to keep the code more focused and granular.
+
+		$this->app->stack(function(Stack $stack, Router $router)
+		{
+			return $stack
+				->middleware('Illuminate\Cookie\Guard')
+				->middleware('Illuminate\Cookie\Queue')
+				->middleware('Illuminate\Session\Middlewares\Reader')
+				->middleware('Illuminate\Session\Middlewares\Writer')
+				->then(function($request) use ($router)
+				{
+					return $router->dispatch($request);
+				});
+			});
 	}
 
 	/**
@@ -21,10 +38,6 @@ class AppServiceProvider extends ServiceProvider {
 	 */
 	public function register()
 	{
-		// This service provider is a convenient place to register your services
-		// in the IoC container. If you wish, you may make additional methods
-		// or service providers to keep the code more focused and granular.
-
 		//
 	}