Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel env() or config() to get environment variable on command line

I know that running php artisan env on the command line shows me the "Current application environment" (such as "production").

But what I want is to be able to see the value of something like env('SESSION_DRIVER') or config('session.driver') straight from the command line.

Is that possible?

(I could not find hints in the docs.)

like image 705
Ryan Avatar asked Oct 12 '17 13:10

Ryan


1 Answers

You can run Tinker:

php artisan tinker

And then use any of these commands:

env('SESSION_DRIVER')
config('session.driver')

Tinker allows you to interact with your entire Laravel application on the command line, including the Eloquent ORM, jobs, events, and more.

https://laravel.com/docs/5.5/artisan#introduction

Alternatively, you could create an Artisan command to show you a value from a config file:

php artisan show-config-value session.driver
like image 99
Alexey Mezenin Avatar answered Sep 18 '22 13:09

Alexey Mezenin