Added a simple php output format#18
Open
martinwittmann wants to merge 2 commits into
Open
Conversation
Owner
|
Hi @martinwittmann, thanks for the contribution! I ran this and got the following $ ./shdotenv -f php
<?php
function __local_env() {
$env = [];
$env["VAR"] = "123";
return $env;
}Apparently it is a function that returns (the contents of .env) as an associative array. Given that shdotenv is a tool for setting environment variables, I am thinking that the following output would be good. Assignments to arbitrary variables should be outside the scope of this project. $ ./shdotenv -f php
<?php
putenv('VAR=123');
?>Note:
However, what you really want seems to be a JSON to PHP code conversion tool. That could probably be easily made using PHP's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A use-case which I find very useful is to add a php output format.
This allows users to generate a simple php file, that can be included into existing projects which eliminates the need to vlucas/dotenv and marginally improves performance since the .env files are not parsed at every http request.