phpgt / config Goto Github PK
View Code? Open in Web Editor NEWManage configuration with ini files and environment variables.
Home Page: https://www.php.gt/config
License: MIT License
Manage configuration with ini files and environment variables.
Home Page: https://www.php.gt/config
License: MIT License
Following on from #3, namespace separator character should be settable.
$config->setSeparator("-");
...
$user = getenv("something-database-user");
$config->setSeparator("/");
...
$user = getenv("something/database/user");
Although using slashes in an environment variable might be a bit mad.
This is a backwards breaking change, so will require implementation in two steps:
withMerge
function, leaving merge
as a mutable function, but start to emit a deprecation notice.merge
function completely.It might actually make more sense to make merge
immutable by default, but due to this decision being made, withMerge is so much more obvious what it does due to the consistency with other with
functions.
By default, this package should look for a config.ini
in the project's root directory and load the contents into environment variables.
There are things to consider for this though:
www
directory.getcwd()
be used? Maybe PHP.Gt webengine could set the working directory to the project root, and so could other projects... so the expected behaviour is to load only from the cwd?not just .ini
s
If there is a config file in place where it is about to be written, FileWriter should override the file's values rather than replace it completely.
Having looked through the tests I couldn't tell where the default config directory is, so I'm fairly sure there's no test for it either :)
Idea (might already work like this, but needs documenting):
run: ./vendor/bin/config-generate deploy stripe.pub="${{ secrets.stripe_pub }}"
stripe.private="${{ secrets.stripe_private }}"`
Try to avoid inception by configuring this package with a config.ini
. An OO methodology is best for configuring the behaviour of where to read configuration.
For namespaced or categorised values, see message in Config::setEnvironmentVariables()
Following on from #3, something within a named section of an ini file should have that name optionally added to the environment variable.
[database]
host = localhost
user = root
$user = getenv("database_user");
// or, with a namespace set:
$user = getenv("something_database_user");
Optionally set a "namespace" for all environment variables to exist within.
With the ini line name = Berty
, setting the namespace with $config->setNamespace("something");
should allow this: $name = getenv("something_name")
.
There are currently no unit tests to test the generation of config files using the config-generate
from the cli.
To make this repo consistent with other getter-style repos in PHP.Gt, implement the Config
object as a TypeSafeGetter.
Write key-value-pairs to ini file by name. This will be used in deployment strategies to place the config.production.ini files in place.
FileFinder::findFilePath
should do this
Separate the responsibility of finding of config files into a new class.
Extra files should override the default config.ini
values if present.
Suggested order:
not just .ini
s
Dependabot needs to be tamed, as per PhpGt/WebEngine#568
[app]
namespace = Example
production.compile = true
production.minify = false
To access the namespace config value, $config->get("app.namespace");
Need to check that dot notation works fine: $config->get("app.production.compile");
not just .ini
s
Of course...
Use one of the following:
These are the two out of many available that have:
Separate parsing out into separate class, for simplicity and readability.
I've come to a point in WebEngine v4 where an array of key value pairs needs to be passed into a function, and all I have access to is the Config object. Rather than building my own array, it'd be useful to get a pre-populated associative array from the class.
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.