Skip to main content

All Questions

1 vote
1 answer
617 views

PHP is not reading .env file

I am using PHP with PDO to connect to my database. I want to start using environment variables, so I used the following terminal command: composer require vlucas/phpdotenv My .env file now contains ...
John Beasley's user avatar
  • 3,099
2 votes
2 answers
3k views

PHP cannot get the environment variables

I have some environment variables as bash variable and other environment variables into a .env file. In my php script I load env variable using this require __DIR__.'/vendor/autoload.php'; use Dotenv\...
Vito Lipari's user avatar
8 votes
1 answer
7k views

Laravel Environment Variables(without default value passed in method) not working inside Artisan Command file

I am using Laravel 6.x for client's project wherein I have built an API in the Artisan Command for syncing data. Now client wants the configuration to be discreet, out of main source code and without ...
Vicky Dev's user avatar
  • 2,213
0 votes
2 answers
2k views

Proper way to call .env file inside project

I wanted to see what would be the proper way to call a .env file inside my project? One of the developers that I'm working with, just told me that everything is setup and that all I would need is to ...
user avatar
1 vote
2 answers
3k views

Laravel 5.2 dynamic environment variables based on user

In my .env file I have two variables App_id: 12345 App_secret: abc123 But I'm wondering if there's a way so that if user userNo2 logs in then it would instead use App_id: 45678 App_secret: abc456 Is ...
Geoff_S's user avatar
  • 5,115
0 votes
1 answer
4k views

How to put the private key contents in dotenv .env file for lumen app? [duplicate]

I want to work with SFTP server in my lumen app and therefore i need to store the private key to access the SFTP server in the .env file (dotenv) I tried this approach: SFTP_PRIVATE_KEY="-----BEGIN ...
Latheesan's user avatar
  • 24.1k
1 vote
3 answers
2k views

How to automatically change the environment by IP

We have three development servers (dev1, dev2, stage) and one production server and some symfony projects. We would like to change the environment automatically. Currently my hack looks like this in '...
ABSimon's user avatar
  • 671
156 votes
13 answers
127k views

Laravel - env() always returns null

I try to find out why my env() helper always returns null. This causes trouble especially in app.php file, where are env() helpers widely used by default. Perhaps any mysterious server setting? My ...
Fusion's user avatar
  • 5,492
67 votes
6 answers
72k views

What is difference between use env('APP_ENV'), config('app.env') or App::environment() to get app environment?

What is difference between use env('APP_ENV'), config('app.env') or App::environment() to get app environment? I know that the env('APP_ENV') will to $_ENV, config('app.env') reads the configuration ...
Miguel Borges's user avatar
14 votes
3 answers
37k views

dotenv requires .env file on production

I'm using dotenv for PHP to manage the environment settings (not lavarel but I tagged it because lavarel also uses dotenv) I have excluded the .env from the code base and I have added the .env....
Sander Visser's user avatar