Questions tagged [phpdotenv]

PHP dotenv is a PHP library that loads environment variables from a text file named .env for easy access from PHP code. This library is based on the Ruby gem (see [ruby-dotenv] tag.) There is also a Node.js module (see [dotenv] tag.)

Loads environment variables from .env to getenv(), $_ENV and $_SERVER automagically.

Code repository: https://github.com/vlucas/phpdotenv

Packagist page: https://packagist.org/packages/vlucas/phpdotenv

83 questions
5
votes
1 answer

Storage path set using .env in Laravel 5.1

I want to configure the storage path in a Laravel 5.1 using the .env file. My bootstrap/app.php looks like this: useStoragePath(getenv('STORAGE_PATH')); and…
Mic Jaw
  • 366
  • 2
  • 8
4
votes
2 answers

How to execute something like sed -i '/^MAIL_DRIVER=/s/=.*/=log/' .env using PHP to update variable value in laravel dotenv file

In Laravel sometime I uptade environment values with sed with: sed -i '/^MAIL_DRIVER=/s/=.*/=log/' .env Can anyone propose and alternative to do this with PHP? UPDATE: I used Laravel/dotenv .env file as a example to give some context to the…
4
votes
4 answers

Laravel 5 Dotenv for specific subdomain

I have a few subdomain in my laravel 5 application, each sub domain have a specific configuration, like mail, nocaptcha, etc. how to set .env file to work with my-specific subdomain ?
comenk
  • 43
  • 1
  • 4
3
votes
1 answer

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']); This is my .env file MY_NEW_VAR=testing Upon…
Manse
  • 37,765
  • 10
  • 83
  • 108
3
votes
1 answer

How to use env variable as reference of other env variable?

I am using Laravel 5.4 and vlucas/phpdotenv library. I wants to take reference of one env variable to other env variable e.g. APP_NAME: JUSTDOIT SIGNUP_KEY: JUSTDOIT_SIGNUP here in SIGNUP_KEY I wants to use whatever APP_NAME it is.
Chintan7027
  • 7,115
  • 8
  • 36
  • 50
3
votes
2 answers

Fatal error: Class 'Dotenv\Dotenv' not found in .../Bootstrap/DetectEnvironment.php on line 24

Not sure why I am getting this message: Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Dotenv\Dotenv' not found in…
tonga
  • 31
  • 1
  • 3
2
votes
1 answer

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 every class like that: $dotenv =…
Raul Perez Tosa
  • 119
  • 1
  • 6
2
votes
1 answer

phpdotenv download many packages

I wanna to use phpdotenv in my project. I read it installation guide and run composer require vlucas/phpdotenv inside my project. Now it downloads many other packages except vlucas/phpdotenv in a folder named vendor as below. Do I need to maintain…
2
votes
1 answer

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 load .env in index.php. But when I tried to get the…
Alkana
  • 53
  • 1
  • 3
2
votes
0 answers

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 sends properly and it does, but I'm confused as…
Majo0od
  • 2,278
  • 10
  • 33
  • 58
2
votes
0 answers

Laravel Lumen function env() returns null sometimes

I am developing api with Lumen 6.2.0 which gets GET request with certain parameters and token. When it gets parameters it process it in a certain way and then encode with a secret key which is in my .env file and then compares result with the token…
ivnku
  • 83
  • 8
2
votes
1 answer

Editing bootstrap.php to customize Dotenv behaviour

I'm not satisfied by the Symfony Dotenv default behaviour, because I would like to have i.e. a .env.override which would override existing environment values. So I would like to add the following code in config/bootstrap.php $envLocal =…
yolenoyer
  • 8,797
  • 2
  • 27
  • 61
2
votes
3 answers

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 noticed that Docker + the Wordpress image is not…
punkbit
  • 7,347
  • 10
  • 55
  • 89
2
votes
1 answer

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 code protected function execute(InputInterface…
PrimuS
  • 2,505
  • 6
  • 33
  • 66
2
votes
3 answers

Dotenv\Dotenv::__construct() is not instance of Dotenv\Loader

I am trying to build a Linkedin API code where I am finding a strange error Fatal error: Uncaught TypeError: Argument 1 passed to Dotenv\Dotenv::__construct() must be an instance of Dotenv\Loader, string given, called in…
Hritam
  • 51
  • 1
  • 1
  • 5