KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

In Laravel, how can I read a variable from the env file? #1929

Closed paulo opened this topic on on Feb 26, 2021 - 2 comments

paulo commented on Feb 26, 2021

I've tried: $hostname = env('DB_FIREBIRD_HOST'); // comes blank tried $hostname2 = $_ENV['DB_FIREBIRD_HOST']; gives me an error.

this is under function settings() from a class that extends report class TRAMSTEST extends KoolReport

I've added to config file 'DB_FIREBIRD_HOST' => env('DB_FIREBIRD_HOST'),

using laravel 8

thank you very much

KoolReport commented on Mar 1, 2021

You use in correct way env('DB_FIREBIRD_HOST') will return the environment value for DB_FIREBIRD_HOST. You try to echo the value to see how. Please make sure that your report is initiated inside controller's action (to make sure Laravel has been initiated)

paulo commented on Mar 2, 2021

thanks. For helping others, I created a config settings, moved everything to config and load from config. It worked perfectly!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None