Comments (9)
This has been fixed. We changed DB_DATABASE="BUILD_${DRONE_BUILD_NUMBER}"
to DB_DATABASE="BUILD_{$DRONE_BUILD_NUMBER}"
.
Turns out ${...}
is used for phpdotenv variables while {$...}
is used for environment variables. You might want to clarify this in the documentation.
from phpdotenv.
phpdotenv follows the correct bash/shell syntax, which is ${...}
for variable expansion and string interpolation. I just tried it in my shell:
$> export DRONE_BUILD_NUMBER=42
$> export DB_DATABASE="BUILD_${DRONE_BUILD_NUMBER}"
$> echo $DB_DATABASE ]
$> BUILD_42
You can also test it with:
source .env && echo $DB_DATABASE
from phpdotenv.
👍
from phpdotenv.
phpdotenv does not properly inline env variables in laravel 5.1
$ printenv | grep MYSQL_USER
MYSQL_USER=root
$ cat .env | grep DB_USERNAME
DB_USERNAME="${MYSQL_USER}"
$ php artisan migrate --force
SQLSTATE[HY000] [1045] Access denied for user '${MYSQL_USER}'@'localhost' (using password: YES)
$ source .env && echo $DB_USERNAME
root
Switching to DB_USERNAME="{$MYSQL_USER}"
inside .env
fixes the issue.
I don't know if this behavior has been changed since laravel 5.1, but it would definitely be good to mention it somewhere visible. Or, since the {$VAR}
version seems to always work, maybe use that example in the documentation?
from phpdotenv.
Laravel 5.1 uses an old version of this package.
from phpdotenv.
https://github.com/vlucas/phpdotenv/tree/1.1
from phpdotenv.
But since Laravel's docs do not specify inline semantics, and people will look to this documentation for guidance, we're left with a very confusing error. I can try and open a PR to fix the Laravel docs, but probably not the only one who would look to your docs first.
Do you think mentioning the old syntax in the main README would be useful? Something along the lines of:
"For old versions of dotenv, use {$VAR} instead of ${VAR}"
from phpdotenv.
I'd say that I'd expect people to look at the readme for the correct version?
from phpdotenv.
Unfortunately, it's not that easy to know what the correct version is when it's vendored like this. Also, 5.1 is the LTS release of Laravel, so it's expected to stick around for a good while still (2 years active dev, 3 years security fixes, starting July 19, 2016).
The docs (https://laravel.com/docs/5.1#environment-configuration) also simply link to the latest version of DotEnv (instead of to ~1.0) adding to the confusion.
from phpdotenv.
Related Issues (20)
- PHP version 7.1 is not supported now HOT 2
- Equals Symbol in last line of multiline variable causes issues. HOT 3
- Save to .env HOT 1
- How to loads many env file, but the extension is .txt HOT 1
- Fatal error: Uncaught Error: Class "Dotenv\Dotenv" not found in HOT 1
- Performance degradation HOT 3
- Question - are there any 'builtin' variables? HOT 3
- Add reader with support for secret files
- loading a .env file from outside the webspace seem to not work
- php 8.2 function getenv() not set HOT 1
- Please dont use $_SERVER HOT 1
- Load AWS system environments HOT 4
- symfony/dotenv Correlation HOT 1
- PHP version 7.4 HOT 1
- How does this help with php_value in .htaccess?
- Is there anyway to use sections created in the .env file? HOT 4
- Fatal error: Uncaught Error: Class "Dotenv\Dotenv" not found in HOT 2
- Can one use Heredoc syntax for multi-line strings? HOT 1
- Failed to parse dotenv file due to unexpected whitespace HOT 1
- Inconsistent result when calling `$this->dotenv->load()` multiple times from PHPUnit
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpdotenv.