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

Add class auto loader #215

Closed
markkap opened this issue Jan 8, 2019 · 1 comment
Closed

Add class auto loader #215

markkap opened this issue Jan 8, 2019 · 1 comment

Comments

@markkap
Copy link

@markkap markkap commented Jan 8, 2019

Autoloading PHP classes just when they are actually required serves to help produce cleaner code as there is no need to worry about proper includes and get better performance as the code is not parsed and loaded into memory if it is not being executed.

To make this work we need to be able to map class names (including namespaces) into file names. For the calmPress core code we are going to use WordPress class and file naming conventions and a root namespace of calmpress.

In addition, there will be an API that plugins and themes can use to register their own loaders. The reason to avoid spl_autoload_register is that there is a performance penalty if PHP needs to activate several autoloaders if the file does not map in the first one. Having this centralized will hopefully reduce the overhead. Obviously, plugins and themes can still call spl_autoload_register instead.

@markkap markkap added this to the 1.0.0 milestone Jan 8, 2019
@markkap
Copy link
Author

@markkap markkap commented Jan 9, 2019

on second thought each plugin and theme will be left to implement its own loader without a centralized API as there seems like there is no possible way to gain any performance or code structure advances from having one.

markkap added a commit that referenced this issue Jan 10, 2019
@markkap markkap closed this Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant