简体   繁体   中英

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 .)

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

您可以在CMD或终端中运行artisan命令 ,该命令显示应用程序正在执行的当前环境

php artisan env

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM