Search code examples
laravel-5laravel-artisan

Laravel 5: How to get config value in artisan console command


I get config values in Laravel like this:

$value = config('app.name');

If I try the same in a method, which is called from an artisan command, then I get the following error message:

[ErrorException] Trying to get property of non-object

Is it possible to get config values from an artisan console command?

I have found a solution for Laravel 4, but there is no such method in Laravel 5.


Solution

  • config() helper use application instance and it can be not available in the console. Try this solution Config::get('app.name')