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
1
vote
1 answer

Lumen on AWS Elastic Beanstalk - .env

I'm trying to deploy a Lumen app in Elastic Beanstalk. The problem is around the .env file, of course it's gitignored, so how can I put that file into the server? I tried to manually create the file after deploying, but the next deploy the file…
1
vote
3 answers

Laravel 5 - Environment Detection by Server Name

I understand with Laravel 5, it uses .env files so we can set specific enivornment values. My question is, is there a way in Laravel 5, to say for example, if ($SERVER_NAME == "my_production_server") { $environment = "production" } And from…
KingKongFrog
  • 13,946
  • 21
  • 75
  • 124
0
votes
1 answer

Bash: what delimiter to use for this string to array conversion to work? (Laravel/dotenv/Sail/Docker Compose)

Laravel Sail should support multiple docker-compose files by configuring them in a dotenv file (.env). The line in my .env file... SAIL_FILES='docker-compose.yml:docker-compose-arm.yml' The part of Sail that handles multiple sail files (I…
Mike
  • 61
  • 1
  • 6
0
votes
0 answers

load environment variables to the global scope

I am currently using vlucas/phpdotenv to load environment variables in my pure php application. I installed the package with composer then loaded it in the index page like: //Load Composer's auto loader require_once realpath(__DIR__ .…
Morena
  • 33
  • 7
0
votes
1 answer

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\Dotenv; $dotenv =…
0
votes
1 answer

Symfony5 SQS consumer invalid access key

I'm trying to consume messages from SQS with the symfony 5 SQS consumer and i'm having an issue when the aws secret key contains special chars like + or \. Here's my .env file…
Alfwed
  • 3,307
  • 2
  • 18
  • 20
0
votes
1 answer

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 cannot change the variable. The…
Zac
  • 1,062
  • 2
  • 7
  • 12
0
votes
1 answer

\[InvalidArgumentException\] Could not find package vlucas/phpdotenv. Couldn't download package

I'm having a problem with vlucas/phpdotenv installation  ~/ nslookup repo.packagist.org Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: repo.packagist.org Address: 54.37.2.184 My composer.json: { "name":…
0
votes
2 answers

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 structure is root/config/db.php. I have…
0
votes
0 answers

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…
Ittisafur
  • 23
  • 4
0
votes
1 answer

github actions multiple dotenv files

I have struggled with how to write this so please bear with me. Ill try and be as clear as possible: Setup: Github repo with 3 branches (Master/Development/Staging) Each branch has a unique dotenv file Repo has VueJS code (but could also be…
ArcticMediaRyan
  • 687
  • 8
  • 32
0
votes
0 answers

no output from .env file in PHP

i'm trying to understand PHP nowadays and i'm stuck on printing out my app's name from a .env file by using "phpdotenv" directory from composer. i've created these files: Index.php, _env.php and .env i'm using xampp - apache and i've configured a…
Ian
  • 9
  • 2
0
votes
3 answers

How to use Doctrine Fixture to load test database for PHP unit testing?

I am trying to set a database environment to test my Doctrine ORM Entity classes, without changing my real database. I followed Symfony's documentation, but when I run php bin/console doctrine:fixtures:load I get the warning: Careful, database…
noam
  • 538
  • 5
  • 19
0
votes
1 answer

How to Change the loaded environement in Laravel

I have to .env files .env.local and .env.pro and I don't know how to switch between files, I tried changing config\app.php from 'env' => env('APP_ENV', 'pro'), to 'env' => env('APP_ENV', 'local'), But I get a blank screen with no errors, How to…
afccc
  • 89
  • 1
  • 7
0
votes
2 answers

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 create a .env file in the root. Here is how the…
user12160926