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

Avoid direct include or require in spl_autoload_register #47

Open
joanhey opened this issue May 27, 2015 · 2 comments
Open

Avoid direct include or require in spl_autoload_register #47

joanhey opened this issue May 27, 2015 · 2 comments

Comments

@joanhey
Copy link
Contributor

joanhey commented May 27, 2015

In https://github.com/dseguy/clearPHP/blob/master/rules/use-smart-autoload.md example:

function my_autoloader($class) {
include 'classes/' . $class . '.class.php';
}

For every include that fail, will generate a warning and increase your log. If you have 4 functions (methods,..) registered using include directly, will create 4 warnings for every request.

It is worse with require, that create a fatal error and stop the execution.

It 's a shame than spl_autoload_register don't work like include_path, that try every path and show the error if all fail.

@dseguy
Copy link
Owner

dseguy commented May 27, 2015

What is your suggestion here ? Add a 'file_exists' to the example, to avoid those errors ?

@joanhey
Copy link
Contributor Author

joanhey commented May 27, 2015

File_exists it's the only solution that I know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants