-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
3.0 - Convert configuration into a 'static' file #1575
Conversation
The speed increase can have other reasons too. INI files aren't stored in opcode cache because they aren't executable for example so they are parsed on every request. Also having a single config file and no opcode cache (or opcode cache with stat on) is still a win because there will be less file hits. So I like the idea of having a single config file. One thing that I've seen in the wild is that people tend to use |
With a PHP code based config file it will still be possible. The config file and bootstrap.php are still code in App. If developers want to get fancy and use additional logic to define their connections they can by removing the |
Yeah I didn't mean it wasn't possible at all, just saying it will be different. |
For sure. The lack of a a class containing the configuration is biggest change I think. I was planning on updating the docs to include an example of conditionally defined data sources. It might also be a good idea to document how to split up the config file for deployment situations where not all of the config needs to be different. |
I decided to remove |
Yeah, I never like that class so I am not complaining. Having only a default and not a |
This is a proof of concept that application configuration can be put into static files quite easily.
Using a .php extension prevents webservers from accidentally serving the configuration file as plain text. This is important for people who do sloppy deployments where the contents of App/ are accessible from the webserver.
Once configuration data has been injected into the various classes it is no longer necessary in Configure. Keeping it in configure only consumes more memory and give the impression that changing data in configure will update the other classes.
This is a simpler/more efficient method for bootstrapping configuration.
- Use consume() it is faster than read() + delete(). - Do not merge config as Configure should be empty and merging is a waste of time.
There is a significant performance drawback (approx. -8%) to using ini files. Using PHP based files actually increases performance (approx. 1.1%) as there are fewer calls to Configure overall. Using PHP files has the advantage of being harder to screw up in various deployment scenarios.
Including a half working config file is probably not a good idea. Move the config file out of the way and force developers to create one.
Save on a few lines of code with inline constructors.
*/ | ||
require __DIR__ . '/cache.php'; | ||
if (!class_exists('App\Controller\AppController')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need another way of doing this, looks like obscure magic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will go away once we finish transitioning to requiring composer.
👍 |
Sweet 👍 |
3.0 - Convert configuration into a 'static' file
], | ||
|
||
/** | ||
* Security ane encryption configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be "Security and encryption..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I suck at keyboards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in ffde282
I think it would make even more sense to provide a built-in solution for that, because almost everybody needs to take care of deploying to different environments where not all config changes (e.g. local dev, central dev server, testing server, production server). How about adding another file? Let's say This way one could create a A bit similiar to the way DokuWiki's configuration works. |
@ravage84 Right now there is only a |
Yes I think that will do. If people need more sophistication they could work it out themselve. If they don't need or want 'local' configs, they could ignore that line. |
This is a prototype/working demonstration of converting the various configuration files in CakePHP into a single 'static' file. I use quotes around static as the file is actually PHP. I originally tried to use ini files, but it negatively affected performance in a fairly significant way. An ini file was ~8% slower on my laptop, which didn't seem worth i. Additionally, ini files have more risk in lazy deployment scenarios as there is a risk of the app.ini being exposed accidentally. Interestingly, switching to the single config file boosted performance ~1%, which I assume came from the reduced number of calls to Configure.
I wanted to get a discussion started around this before doing much more work on it.
Once this issue is settled my plan is to finalize the work around composer and get the code to a point where the cakephp-app repo could be split off and be used for further development. See this wiki page for more details on those plans.