mirror of
https://github.com/laravel/laravel.git
synced 2025-02-20 11:53:14 +08:00
Add scheduled commands.
This commit is contained in:
parent
e3e7cc499f
commit
a7e6a89c91
@ -1,6 +1,7 @@
|
||||
<?php namespace App\Console;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as 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
app/Exceptions/Handler.php
Normal file
31
app/Exceptions/Handler.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
@ -19,24 +19,4 @@ class Kernel extends HttpKernel {
|
||||
'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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ $app->singleton(
|
||||
|
||||
$app->singleton(
|
||||
'Illuminate\Contracts\Debug\ExceptionHandler',
|
||||
'Illuminate\Foundation\Debug\ExceptionHandler'
|
||||
'App\Exceptions\ExceptionHandler'
|
||||
);
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user