How to use Console Kernel in Laravel PHP?

2020-07-11 09:26发布

问题:

I am reading the documentation at Laravel under the heading Architecture Concepts.

I am unable to understand application and usage of Console Kernel .(not the Http Kernel) However, I googled out and found these links

https://laravel.com/api/5.2/Illuminate/Foundation/Console/Kernel.html https://laravel.com/api/5.3/Illuminate/Contracts/Console/Kernel.html

But I can't understand anything with that API !

回答1:

The HTTP Kernel is used to process requests that come in through the web (HTTP). Website requests, AJAX, that kind of stuff.

The Console Kernel is used when you interact with your application from the command line. If you use artisan, or when a scheduled job is processed, or when a queued job is processed, all of these actions go through the Console Kernel.

Basically, if you go through index.php, you'll be using the HTTP Kernel. Most everything else will be using the Console Kernel.