phpdotenv

Unable to read environment variables

有些话、适合烂在心里 提交于 2021-02-05 07:09:49
问题 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 executing the command I get the following string(7) "testing" All good so far.... But now if I want to use environment variables to override the setting it returns an error. First I set the environment variable export MY_NEW_VAR="something_else" Then

Unable to read environment variables

徘徊边缘 提交于 2021-02-05 07:06:24
问题 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 executing the command I get the following string(7) "testing" All good so far.... But now if I want to use environment variables to override the setting it returns an error. First I set the environment variable export MY_NEW_VAR="something_else" Then

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

流过昼夜 提交于 2021-02-04 19:32:47
问题 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 any fallback values as possible. That means I must define the configs in the .env file and use the env() method without any fallback default values. This must be possible inside Laravel Artisan command class files, but it is not working as intended when I use the env method in the code as below:

Load environment variables from env file with Docker and PHP

馋奶兔 提交于 2020-01-04 14:20:33
问题 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 easy to setup. While quite trivial to set up in node, etc. See the ".env" file below that sits same dir as the docker-compose.yml: WORDPRESS_DB_NAME=wp_xxxx WORDPRESS_DB_USER=xxxxxx WORDPRESS_DB_PASSWORD=xxxxxx WORDPRESS_DB_HOST=xxxxxxxx The official

How to override env variables in Laravel Dusk

爷,独闯天下 提交于 2019-12-29 02:09:45
问题 Unfortunately config(['key' => 'newValue']) doesn't work in a Dusk setup (for overriding a config value), presumably because it would change the config of the system running the test rather than the experience of the headless browser that gets opened to execute the flow. And sometimes I can see no way around needing to temporarily change an env value for a certain Dusk test. E.g. temporarily set QUEUE_DRIVER=sync when usually it is 'dusk-connection', but in one particular test, I need to

How to override env variables in Laravel Dusk

主宰稳场 提交于 2019-12-29 02:09:15
问题 Unfortunately config(['key' => 'newValue']) doesn't work in a Dusk setup (for overriding a config value), presumably because it would change the config of the system running the test rather than the experience of the headless browser that gets opened to execute the flow. And sometimes I can see no way around needing to temporarily change an env value for a certain Dusk test. E.g. temporarily set QUEUE_DRIVER=sync when usually it is 'dusk-connection', but in one particular test, I need to

Laravel 5 - Environment Detection by Server Name

泪湿孤枕 提交于 2019-12-23 02:58:05
问题 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 that it uses production values. My thinking is, I'd like all the environments and their variables placed in one file or directory, or whatever so we can deploy the whole build without any manual intervention, and we can check this all into our code

PHP Fatal error: Class 'Dotenv' not found in

淺唱寂寞╮ 提交于 2019-12-11 04:46:39
问题 I've a project I try to run it but I am getting a following error: PHP Fatal error: Class 'Dotenv' not found in `/home/maras/Documents/eCodile/debtorcare/server/bootstrap/app.php on line 5` I'm struggling with this error during trying to execute a php artisan start I tried to reinstall all dependencies but it didn't work. I've just tried to run some commands based on other similar problems I found in the Internet but any of them worked. I tried ie: composer require vlucas/phpdotenv --prefer

Is it a good idea to edit .env dynamically in Laravel 5?

房东的猫 提交于 2019-12-11 00:59:46
问题 I am building an admin panel, so I need to make some core settings (like smtp settings, etc) of my Laravel 5 app configurable to end users through front-end interface. My initial thoughts were to use database as a settings storage alongside caching(to avoid issuing database calls every time a config value is accessed). However, it appears, that Facades are loaded after config files, thus the code below doesn't work: <?php // app/config/custom_settings.php return [ 'key' => Cache::get('key');

Laravel 5 Dotenv for specific subdomain

别等时光非礼了梦想. 提交于 2019-12-06 04:46:45
问题 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 ? 回答1: Yes, you can use separate .env files for each subdomain so if you use env variables in your config it will work without great modifications. Create bootstrap/env.php file with the following content: <?php $app->detectEnvironment(function () use ($app) { if (!isset($_SERVER['HTTP_HOST'])) { Dotenv::load($app