Add scheduled commands.

This commit is contained in:
Taylor Otwell 2014-11-18 22:48:38 -06:00
parent e3e7cc499f
commit a7e6a89c91
4 changed files with 39 additions and 38 deletions

View File

@ -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 \Illuminate\Console\Scheduling\Schedule $schedule
* @param \Symfony\Component\Console\Output\OutputInterface $output * @return void
* @return int
*/ */
public function handle($input, $output = null) protected function schedule(Schedule $schedule)
{ {
try $schedule->artisan('foo')
{ ->hourly();
return parent::handle($input, $output);
}
catch (Exception $e)
{
$this->reportException($e);
$this->renderException($output, $e);
return 1;
}
} }
} }

View File

@ -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);
}
}

View File

@ -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);
}
}
} }

View File

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