oscarotero / env Goto Github PK
View Code? Open in Web Editor NEWSimple library to read environment variables and convert to simple types.
License: MIT License
Simple library to read environment variables and convert to simple types.
License: MIT License
This is about values like 0755
or 0664
which are used for file permissions. When using DIR_PERM=0755
then env()
will convert this to int(755)
but the correct value should have been int(493)
.
php > var_dump( ctype_digit( '0755' ) );
bool(true)
php > var_dump( (int) '0755' );
int(755)
php > var_dump( (int) 0755 );
int(493)
To support this a self::CONVERT_OCTAL
option is probably needed which can be used to run before the current integer conversion. https://www.php.net/manual/de/function.octdec.php#85170 might be helpful.
Thoughts?
PHP dotenv v5 has switched to using the $_SERVER
global as the default storage instead of the putenv()
$_ENV
variable (see v4 fallback chain). See this comment by @GrahamCampbell for the reasoning behind this change.
What are you thoughts about adding a new Env::USE_SERVER_ARRAY
option which reads the data from the $_SERVER
variable?
Related: #3.
I'm currently using a shared webhost and as it turns out, they have putenv()
(and consequently getenv()
) disabled. And since your library is using getenv()
, it doesn't work in that setup.
Since I might not be the only one to ever run into this issue, I wanted to ask whether your library could be updated to use $_ENV[]
instead? I'm not very PHP-savvy, so, I might be asking the impossible here...
Thank you for your consideration.
(Link to related issue I posted in roots/bedrock.)
Hello @oscarotero !
Would it be possible to add a second parameter to env($name, $defaultValue)
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.