A little while back I was engaged into a project that centers around Yii2. Though it has one problem. Configuration. Yep. The configuration for Yii2 is a total mess.
To give you a better perspective on how it works, each module has its own configuration folder and a common configuration folder. Lastly each having their own
To wire all of them together it does
include throughout the header of a config file. Adding to the mess is production config values are included in the SCM! To remedy this I have to do three things
- Centralize the configuration
- Config values utilize environment variables from an
- Centralize the public folder
Throughout the whole ordeal I encountered certain problems that gave me an initial perspective on how Yii2 works in the background. I have to do some quirks in order to go around these problems and make the site work.
base_pathis based on the module base directory. It created a problem whereas aliases for assets, views, and config files will resolve to the module's base path instead of the newly altered structure.
errorHandlercomponents when included in the console config creates an error in the default
The two most significant changes on the Yii project is the addition of a
public/ folders with their respective files and a console runner that can run the changes made throughout the structure.
One of the biggest advantages in the new structure is you don't have to worry about same values in your configs throughout in your project/module directories. Lastly it provides a reasonable improvement in leaving out sensitive values out from the SCM.
The code speaks for itself. If you have questions please contact me over Twitter.