Show data from the .env file in blade

0

I would like to read some data from the file .env on page .blade.php , but some do not work, for example, I'm using the following way:

apkey: {{env('PUSHER_APP_KEY')}} #ler chave PUSHER_APP_KEY                   
key: {{config('database.base')}} #ler chave base do arquivo app/database.php
broadcasting:{{config('broadcasting.key')}} #ler chave key do arquivo app/broadcasting.php

Where my file .env is set to the following values

PUSHER_APP_ID = minhaid
PUSHER_APP_KEY = minhachave
PUSHER_APP_SECRET = minhasenha
PUSHER_APP_CLUSTER = us2

An excerpt from my broadcasting.php file looks like this:

return [    
  'default' => env('BROADCAST_DRIVER', 'null'),
  'key'  => env('PUSHER_APP_KEY'),

An excerpt from my file database.ph p looks like this:

 return [
   'base' => env('DB_HOST', '127.0.0.1'), 
      /* ... */

Only the return from database.php works in the example above, I can not read data from broadcast . How do I read from file .env ?

    
asked by anonymous 28.11.2018 / 14:03

1 answer

0

Just put the name of the key that is in the file .env , example:

APP_ENV=local
APP_KEY=base64:M2eN0OPMVR/CDoUSlI+bZW1sgqgmkqC/l7R8omQx8Dc=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=senha

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=

How to use?

+----------------------------------+---------------------------------------+
| Comando                          | Saída                                 |
+----------------------------------+---------------------------------------+
| env('APP_ENV');                  | local                                 |
+----------------------------------+---------------------------------------+
| env('DB_CONNECTION');            | mysql                                 |
+----------------------------------+---------------------------------------+
| env('BROADCAST_DRIVER');         | log                                   |
+----------------------------------+---------------------------------------+

and so on.

    
08.12.2018 / 01:25