Skip to content

Commit a7e6a89

Browse files
committed
Add scheduled commands.
1 parent e3e7cc4 commit a7e6a89

File tree

4 files changed

+39
-38
lines changed

4 files changed

+39
-38
lines changed

app/Console/Kernel.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php namespace App\Console;
22

33
use Exception;
4+
use Illuminate\Console\Scheduling\Schedule;
45
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
56

67
class Kernel extends ConsoleKernel {
@@ -15,26 +16,15 @@ class Kernel extends ConsoleKernel {
1516
];
1617

1718
/**
18-
* Run the console application.
19+
* Define the application's command schedule.
1920
*
20-
* @param \Symfony\Component\Console\Input\InputInterface $input
21-
* @param \Symfony\Component\Console\Output\OutputInterface $output
22-
* @return int
21+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
22+
* @return void
2323
*/
24-
public function handle($input, $output = null)
24+
protected function schedule(Schedule $schedule)
2525
{
26-
try
27-
{
28-
return parent::handle($input, $output);
29-
}
30-
catch (Exception $e)
31-
{
32-
$this->reportException($e);
33-
34-
$this->renderException($output, $e);
35-
36-
return 1;
37-
}
26+
$schedule->artisan('foo')
27+
->hourly();
3828
}
3929

4030
}

app/Exceptions/Handler.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php namespace App\Exceptions;
2+
3+
use Exception;
4+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
5+
6+
class Handler extends ExceptionHandler {
7+
8+
/**
9+
* Report or log an exception.
10+
*
11+
* @param \Exception $e
12+
* @return void
13+
*/
14+
public function report(Exception $e)
15+
{
16+
return parent::report($e);
17+
}
18+
19+
/**
20+
* Render an exception into a response.
21+
*
22+
* @param \Illuminate\Http\Request $request
23+
* @param \Exception $e
24+
* @return \Illuminate\Http\Response
25+
*/
26+
public function render($request, Exception $e)
27+
{
28+
return parent::render($request, $e);
29+
}
30+
31+
}

app/Http/Kernel.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,4 @@ class Kernel extends HttpKernel {
1919
'Illuminate\Foundation\Http\Middleware\VerifyCsrfToken',
2020
];
2121

22-
/**
23-
* Handle an incoming HTTP request.
24-
*
25-
* @param \Illuminate\Http\Request $request
26-
* @return \Illuminate\Http\Response
27-
*/
28-
public function handle($request)
29-
{
30-
try
31-
{
32-
return parent::handle($request);
33-
}
34-
catch (Exception $e)
35-
{
36-
$this->reportException($e);
37-
38-
return $this->renderException($request, $e);
39-
}
40-
}
41-
4222
}

bootstrap/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
$app->singleton(
4040
'Illuminate\Contracts\Debug\ExceptionHandler',
41-
'Illuminate\Foundation\Debug\ExceptionHandler'
41+
'App\Exceptions\ExceptionHandler'
4242
);
4343

4444
/*

0 commit comments

Comments
 (0)