E
E
EVOSandru62018-08-09 23:09:28
linux
EVOSandru6, 2018-08-09 23:09:28

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

The site itself is working, and the data, for example, connecting the database, should be pulled from here.
For in the file /var/www/sitename/config/database.php pgsql I did not touch:
...
'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',
        ],
...

On any attempt to get the value of a variable, I catch null :
Route::get('/test-mail',function (MailerInterface $mailer) {
    dump(env('MAIL_HOST'));
    dump(env('APP_NAME'));
    dump(config('APP_NAME'));
});

Why can't I access these variables and why is the database under my control?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor, 2018-08-09
@EVOSandru6

php artisan config:clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question