I have a use case where we need to modify application flow if the application is being run from the command line via Artisan (migrations, seeds, route:list).
In Laravel
As of Laravel 5.1 this works... $app->runningInConsole() https://laravel.com/api/5.1/Illuminate/Foundation/Application.html
$app->runningInConsole()
Basic usage:
if (! $app->runningInConsole()) { // do something }