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

Comments

Projects
None yet
1 participant
@markkap
Copy link

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

This comment has been minimized.

Copy link
Author

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
You can’t perform that action at this time.