Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert $CFG options to be YAML or JSON driven #42

Open
btopro opened this issue Jan 2, 2018 · 4 comments
Open

Convert $CFG options to be YAML or JSON driven #42

btopro opened this issue Jan 2, 2018 · 4 comments

Comments

@btopro
Copy link
Contributor

btopro commented Jan 2, 2018

It seems like configuration settings are more or less thrown in as people think of them into config-dist.php. Would it possibly be easier to read as well as modify and put into version control if this was abstracted to a yaml or json file that config then loads in? This would also make it easier to write a CLI / YO that could write the config options automatically for people increasing devUX down stream

@csev
Copy link
Collaborator

csev commented Jan 2, 2018

Definitely a thought - because of the PHP runtime, pre-compiling, and APC cache, putting config in PHP is effectively 100% free. A JSON or YAML would be an extra file open on every request / response cycle. Core code needs to be cheap and fast.

Now a possible solution would be to write a class or change the ConfigInfo class to point to a YAML or JSON file - then the config.php file would just use ConfigInfo to load the file and set all the variables. Best of both worlds - scorching fast and easy flexibility.

Also the "config-dist.php" -> "config.php" convention came from Moodle :) They have auto configuration that writes the file. Tsugi could support auto-config whether it was PHP, YAML, or JSON.

@btopro
Copy link
Contributor Author

btopro commented Jan 2, 2018

D8/Backdrop write to yaml / parse back in then cache the reference.

You could also cheat and name the file config.yaml.php and opcache would store it ;)

@jonespm
Copy link
Collaborator

jonespm commented Oct 26, 2019

I think the config looks okay but could be more readable/organized. The CFG doesn't actually start until a few pages in where in the Moodle Version it's right at the top and easier to tell what you have to set.

Wordpress looks like it uses define in a php file. That seems readable too and not many settings at all.

The performance of ini files and parse_ini_file also seems to be pretty high, and the last comment there about reading the file, caching it and loading it seems interesting. I also noticed this php library and looks like they might have built in cache, no idea of the performance. https://github.com/hassankhan/config

Might be worth using something like that if this was changed

I don't know how much benefit one format would have over another though, but realistically the performance cost of reading in a file seems negligible compared to any database access if the page does that.

@csev
Copy link
Collaborator

csev commented Oct 27, 2019

I don't like YAML or ini files. PHP is the quickest and most high performance way to do this - it is compiled dynamically.

The layout of config-dist.php (i.e. not all the good stuff is at the top) is just because of a lot of evolution and no refactoring to clean things up. One thing that made things a lot more complex was things like Lessons, apphome, memcache, and Koseu. This becomes a combination of the Tsugi configuration and the Koseu configuration so it get s a little unweildly. There is also the

ConfigInfo class that is supposed to document everything that tends to fall behind config-dist.php

If I was going to do anything, it would be to separate the config.php into Tsugi and Koseu settings and put the Koseu settings in the parent directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants