Issue accessing .env file on Envoyer server setup
Hi all,
I'm having some issues accessing my .env file from a vanilla php file in my /public folder (it is used as an override for a file download when a certain route is called). The parse_ini_file only returns false when logging it.
I have the following code that I cannot get to work. It was working file on a non-Envoyer server and seemed to be working for a while on the Envoyer setup but we noticed that it randomly stopped working on our beta/prd servers (still works locally in a Homestead config).
<?php
$creds = parse_ini_file('../.env');
$dbHost = $creds['DB_HOST'] ?? 'localhost';
$dbUser = $creds['DB_USERNAME'] ?? 'narcboxwebdefault';
$dbPass = $creds['DB_PASSWORD'];
I've tried stuff like the following to make the path dynamic without success:
$envUrl = __DIR__ . '/../.env';
echo $envUrl;
I'm at a bit of a loss and all I can think of is that the .env is simlinked instead actually being there which I'm not sure if that is causing the issue.
For some background and those not familiar with Envoyer, my project's base directory is:
/home/forge/www.site.com/current
The actual .env that is symlinked lives at:
/home/forge/www.site.com
Some more background: Running Laravel 6.20.27 PHP 7.4.18
Note: my dev environment is running PHP7.4
Any help with this is appreciated as I've spent way too much time on what should be a simple issue :)
Please or to participate in this conversation.