Created
January 21, 2021 14:01
Autoloading with native PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
spl_autoload_register(function ($classname) { | |
$classname = str_replace('App', 'src', $classname); | |
$classname = str_replace('\\', '/', $classname); | |
$classname .= '.php'; | |
require_once $classname; | |
}); | |
$test = new App\NativeAutoload |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Ce fichier se trouve au chemin src/NativeAutoload.php | |
namespace App; | |
class NativeAutoload { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment