Detect if running from the command line in Laravel 5

后端 未结 4 475
感情败类
感情败类 2021-02-03 22:16

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

4条回答
  •  猫巷女王i
    2021-02-03 22:53

    As of Laravel 5.1 this works... $app->runningInConsole() https://laravel.com/api/5.1/Illuminate/Foundation/Application.html

    Basic usage:

    if (! $app->runningInConsole()) {
     // do something
    }
    

提交回复
热议问题