90 questions
1
vote
1
answer
83
views
Custom env file directory in Laravel 11
I am trying to set a custom directory for the .env file in Laravel 11. I've seen various solutions and it half working, but not loading the right env file in the controller.
app.php:
use Illuminate\...
0
votes
0
answers
39
views
.env is being hashed? [duplicate]
I am resolving .env like this.
$dotenv = new Dotenv();
$dotenv->load(__DIR__ . '/../.env');
$_ENV seems to be loaded as expcted, when I dumping it. However getenv('') just returns false for any of ...
2
votes
1
answer
832
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 ...
1
vote
2
answers
221
views
Symfony framework.lock with .env set-up
Problem
I need to set up Symfony framework.yaml parameter framework.lock with 2+ memcached servers using .env. But when I try to do so, it does not recognize 2 servers, but only one, and with a glitch....
-1
votes
1
answer
209
views
Heroku Symfony app Unable to read the "/tmp/build_2f06b5cf/.env" environment file
After updating composer to v1 to v2, my build on heroku is failing, error message :
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! PHP ...
-1
votes
1
answer
2k
views
How to limit a package's dependency to a certain PHP version in Composer? [duplicate]
Our production server is PHP 5.5.24. A package I need (vlucas/dotenv) requires in its composer.json:
"symfony/polyfill-ctype": "^1.17"
Unfortunately version 1.20 of that symfony ...
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\...
5
votes
1
answer
7k
views
How to use phpdotenv library on my whole project?
I started a project using composer and donlowaded the package vlucas/phpdotenv. I would like to call the $_ENV['name'] for example in my whole project without needing to instantiate the dot env in ...
0
votes
1
answer
1k
views
Laravel (vlucas/phpdotenv) changing env values dynamically
In my test cases, I try to change some of the environment variables to create better test case coverage.
Laravel by default, only support get environment variable by env($key, $default = null), I ...
1
vote
1
answer
620
views
How to load custom .env file in Laravel console command?
I have this console command code:
class MyCommand extends Command
{
protected $signature = 'custom:mycommand {domain}';
// ...
public function handle()
{
$domain = $this->...
0
votes
2
answers
5k
views
How do I solve the error "Fatal error: require(): Failed opening required '../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') ?"
So I am using vlucas/phpdotenv in my php application to store and use environment variables. I have created a db.php file which contains the configuration of my database connection. The folder ...
-1
votes
3
answers
2k
views
Path issue with PHP Dotenv
Im new to this, and have been trying for a few hours to get this to work. I have a project with this structure:
/API
-.env
/Processor
-index.php
The contents of my .env file is this:
...
0
votes
0
answers
436
views
Notice: Undefined index: APP_NAME returns null
I'm having a problem setting up phpdotenv in my PHP project.
Notice: Undefined index: APP_NAME in /media/undefined/work/Php/miniframework/bootstrap/app.php on line 17
My folder structure
miniframework
...
2
votes
1
answer
8k
views
Setup File .env in Slim Framework
I'm new to slim framework. I'd try to add .env file in root folder project and then I want to access the value inside .env file. I've tried use this package https://github.com/vlucas/phpdotenv and ...
2
votes
0
answers
2k
views
Configuring symfony to send mail via Postfix
After installing Postfix on my Ubuntu server and getting my Symfony application running, I'm attempting to have the system send emails via Postfix. I tested it out in the terminal to make sure that it ...
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 ...
1
vote
3
answers
5k
views
Undefined type 'Dotenv\Dotenv". intelephense(1009)
I need help with this error in the screenshot below
I am using PHP 7.2 and a 3rd party composer - "composer require vlucas/phpdotenv" v4.1.4.
I define the base path but there is an error in the ...
6
votes
1
answer
4k
views
Return datatype from .env in Laravel
I want to have dynamic seeders based on my environment. (eg in testing I want so only seed 100 rows, whereas local it would be 10'000).
I've created seeder.php in the config, which is calling values ...
0
votes
1
answer
258
views
Desperately looking for a non empty $_ENV in Laravel
I have a console task ran through:
$schedule->command('process:job')
->cron('* * * * *')
->withoutOverlapping();
The task is run, it can invoke different services, ...
0
votes
2
answers
73
views
PHPDoc references a dotenv entry
How should i reference on a PHPdoc block that if the variable is not present it will check a dotenv setting for it?
/**
* Class constructor.
*
* Created Class Object.
*
* @param null $url -...
3
votes
4
answers
22k
views
Load environment variables from env file with Docker and PHP
How to use dotenv variables set in the Docker file, passed to a Php application?
Recently tried to use a ".env" file with a set of key paired values to use across different configuration files, but ...
2
votes
1
answer
8k
views
Symfony 4 Console Command not reading env vars
I have a small console command where I'd like to read some environment variables, but it does not seem to read the vars from the .env file or the server configs in the console (php file works)
The ...
3
votes
1
answer
12k
views
Unable to read environment variables
I have a simple Symfony project, using "symfony/dotenv": "4.3.*", in the composer.json and trying to read in the value of an environment variable.
This is my command:
var_dump($_ENV['MY_NEW_VAR']);
...
0
votes
0
answers
163
views
After using docker-compose to build a dev copy of a server/website from a YML, I am getting fatal PHP errors related to dotenv?
I was given a docker-compose.yml file from the agency that created our website in order to build a local dev copy of our existing website now that I've taken over managing our Wordpress e-com.
...
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 ...