Skip to content

Avoid direct include or require in spl_autoload_register #47

@joanhey

Description

@joanhey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions