Browse Source

Add scheduled commands.

Taylor Otwell 9 years ago
parent
commit
a7e6a89c91
4 changed files with 39 additions and 38 deletions
  1. 7 17
      app/Console/Kernel.php
  2. 31 0
      app/Exceptions/Handler.php
  3. 0 20
      app/Http/Kernel.php
  4. 1 1
      bootstrap/app.php

+ 7 - 17
app/Console/Kernel.php

@@ -1,6 +1,7 @@
 <?php namespace App\Console;
 <?php namespace App\Console;
 
 
 use Exception;
 use Exception;
+use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 
 
 class Kernel extends ConsoleKernel {
 class Kernel extends ConsoleKernel {
@@ -15,26 +16,15 @@ class Kernel extends ConsoleKernel {
 	];
 	];
 
 
 	/**
 	/**
-	 * Run the console application.
+	 * Define the application's command schedule.
 	 *
 	 *
-	 * @param  \Symfony\Component\Console\Input\InputInterface  $input
-	 * @param  \Symfony\Component\Console\Output\OutputInterface  $output
-	 * @return int
+	 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
+	 * @return void
 	 */
 	 */
-	public function handle($input, $output = null)
+	protected function schedule(Schedule $schedule)
 	{
 	{
-		try
-		{
-			return parent::handle($input, $output);
-		}
-		catch (Exception $e)
-		{
-			$this->reportException($e);
-
-			$this->renderException($output, $e);
-
-			return 1;
-		}
+		$schedule->artisan('foo')
+				 ->hourly();
 	}
 	}
 
 
 }
 }

+ 31 - 0
app/Exceptions/Handler.php

@@ -0,0 +1,31 @@
+<?php namespace App\Exceptions;
+
+use Exception;
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+
+class Handler extends ExceptionHandler {
+
+	/**
+	 * Report or log an exception.
+	 *
+	 * @param  \Exception  $e
+	 * @return void
+	 */
+	public function report(Exception $e)
+	{
+		return parent::report($e);
+	}
+
+	/**
+	 * Render an exception into a response.
+	 *
+	 * @param  \Illuminate\Http\Request  $request
+	 * @param  \Exception  $e
+	 * @return \Illuminate\Http\Response
+	 */
+	public function render($request, Exception $e)
+	{
+		return parent::render($request, $e);
+	}
+
+}

+ 0 - 20
app/Http/Kernel.php

@@ -19,24 +19,4 @@ class Kernel extends HttpKernel {
 		'Illuminate\Foundation\Http\Middleware\VerifyCsrfToken',
 		'Illuminate\Foundation\Http\Middleware\VerifyCsrfToken',
 	];
 	];
 
 
-	/**
-	 * 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)
-		{
-			$this->reportException($e);
-
-			return $this->renderException($request, $e);
-		}
-	}
-
 }
 }

+ 1 - 1
bootstrap/app.php

@@ -38,7 +38,7 @@ $app->singleton(
 
 
 $app->singleton(
 $app->singleton(
 	'Illuminate\Contracts\Debug\ExceptionHandler',
 	'Illuminate\Contracts\Debug\ExceptionHandler',
-	'Illuminate\Foundation\Debug\ExceptionHandler'
+	'App\Exceptions\ExceptionHandler'
 );
 );
 
 
 /*
 /*