Answer the question
In order to leave comments, you need to log in
Why can't I get env variables via env('VAR_NAME') in Laravel 5.6 on linux?
Good afternoon,
Can't access variables in .env file directly. String data without quotes.
File snippet:
COMPOSE_PROJECT_NAME=app
APP_NAME=string
APP_ENV=local
APP_KEY=base64:string/string/string=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DEBUGBAR_ENABLED=false
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=string
DB_USERNAME=postgres
DB_PASSWORD=postgres
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=string
MAIL_PASSWORD=string
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
SMSC_DRIVER=string.com
[email protected]
SMSC_KZ_PASSWORD=string
SMSC_KZ_URL=https://string.string/string/string.php
...
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
...
Route::get('/test-mail',function (MailerInterface $mailer) {
dump(env('MAIL_HOST'));
dump(env('APP_NAME'));
dump(config('APP_NAME'));
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question