phplaravellaravel-5environment-variables

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


Solution

  • 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