-
Notifications
You must be signed in to change notification settings - Fork 345
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
Do not use F3 for configuration management #1261
Conversation
c536cd7
to
860f07c
Compare
Fatfree is badly designed and should not have lived past 2005. Most notably, it relies on a single huge singleton object, which makes testing difficult. What is worse, the unholy things it does to error handling makes PHPStan and PHPUnit crash. For these reasons and other pains, selfoss will be gradually removing its use. Configuration values are read throughout the codebase so I decided to tackle those first. Ideally, we would construct a configuration container using something like <https://gitlab.com/Khartir/typed-config> but that requires more recent PHP version than we support. Other configuration libraries either suffer from the same problem, are untyped like f3 was (domains of the options are known so we should not have to cast the string loaded from the ini file at the point of use), or are completely undocumented. Custom solution had to be implemented. This patch adds `helpers\Configuration` class, which will load data from `config.ini` and environment variables and store them in properties. The class is injected by Dice into whichever other class that needs access to configuration. In addition to reducing the percentage of code paths tainted by F3, it will also bring better developer experience since editors and other tools can make use of the property annotations. Since the default values of configuration option are now stored as default values of the class properties, `defaults.ini` is no longer used. It will still be included in the distribution zipball for convenience (generated from the code. In the future, we can move the option descriptions into the class and have the options documentation generated as well.
while validating the changes from the previous commit.
It requires an extra option so let’s warn about that. And also do the same for wallabag.
It has been years since Wallabag 2 has been released so let’s allow people to remove wallabag_version=2 from their configs by making it the default value. This is potentially breaking change but hopefully, no one uses Wallabag 1 any more.
860f07c
to
7f4eae0
Compare
This will allow us to share them with tests and also make PHPStan aware of them.
7f4eae0
to
d1ca410
Compare
Out of curiosity, what is wrong with Fat Free Framework? Why don't you recommend it? |
There is just so many issues and problems with it I had to work around in selfoss. Many of them just stem out of its old age and are impossible to fix without breaking backwards compatibility and massive rewrite unfortunately. These are just a few I remember at the top of my head:
|
Fuck, I forgot we still use this piece of work. Just spent almost three hours debugging why Symfony console in #1283 fails with |
Fatfree is badly designed and should not have lived past 2005. Most notably, it relies on a single huge singleton object, which makes testing difficult. What is worse, the unholy things it does to error handling makes PHPStan and PHPUnit crash. For these reasons and other pains, selfoss will be gradually removing its use. Configuration values are read throughout the codebase so I decided to tackle those first.
Ideally, we would construct a configuration container using something like https://gitlab.com/Khartir/typed-config but that requires more recent PHP version than we support. Other configuration libraries either suffer from the same problem, are untyped like f3 was (domains of the options are known so we should not have to cast the string loaded from the ini file at the point of use), or are completely undocumented. Custom solution had to be implemented.
This patch adds
helpers\Configuration
class, which will load data fromconfig.ini
and environment variables and store them in properties. The class is injected by Dice into whichever other class that needs access to configuration. In addition to reducing the percentage of code paths tainted by F3,it will also bring better developer experience since editors and other tools can make use of the property annotations.
Since the default values of configuration option are now stored as default values of the class properties,
defaults.ini
is no longer used. It will still be included in the distribution zipball for convenience (generated from the code.In the future, we can move the option descriptions into the class and have the options documentation generated as well.