Well, actually, you could solve the problem using the internal resource used by Laravel 5
. It is a library (which is already installed in the Laravel 5
) called Dotenv
.
See how to use:
$dot = new Dotenv\Dotenv(base_path());
dd($dot->load());
The result is:
array:20 [▼
0 => "APP_ENV=local"
1 => "APP_DEBUG=true"
2 => "APP_KEY=PzWPA7lYetAsN9aGmHuSsdVaNh7DfCjt"
3 => "APP_URL=http://localhost"
4 => "DB_HOST=127.0.0.1"
5 => "DB_DATABASE=homestead"
6 => "DB_USERNAME=homestead"
7 => "DB_PASSWORD=secret"
8 => "CACHE_DRIVER=file"
9 => "SESSION_DRIVER=file"
10 => "QUEUE_DRIVER=sync"
11 => "REDIS_HOST=127.0.0.1"
12 => "REDIS_PASSWORD=null"
13 => "REDIS_PORT=6379"
14 => "MAIL_DRIVER=smtp"
15 => "MAIL_HOST=mailtrap.io"
16 => "MAIL_PORT=2525"
17 => "MAIL_USERNAME=null"
18 => "MAIL_PASSWORD=null"
19 => "MAIL_ENCRYPTION=null"
]
The information is returned this way, as it was not meant to be used as array
, and yes to be used by the function getenv
. The Dotenv
internally uses the function putenv
, to save file information .env
.
Sorry to ask, but no . env does not have much data that would be useful to me, what the reason exactly?
– Guilherme Nascimento
I need to precisely access the connection data and then use it to generate reports using the Jasperphp library. So it would be nice if I could access the connection data directly from . env.
– geekcom
What
getenv('APP_ENV')
returns?– Guilherme Nascimento
returns:
"local"
– geekcom