Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions proposed/package-oriented-autoloader.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,16 @@ specification.
<?php
// if this closure is registered in a file at /path/to/project/autoload.php ...
spl_autoload_register(function ($absoluteClass) {
$namespacePrefix = 'Foo\Bar';
$namespacePrefix = 'Foo\\Bar\\';
$baseDirectory = __DIR__ . '/src/';
if (0 === strncmp($namespacePrefix, $absoluteClass, strlen($namespacePrefix))) {
$relativeClass = substr($absoluteClass, strlen($namespacePrefix));
$relativeFile = str_replace('\\', '/', $relativeClass) . '.php';
$path = $baseDirectory . $relativeFile;
if (is_readable($path)) {
require $path;
return true;
}
}
return false;
});

// ... then the following line would cause the autoloader to attempt to load
Expand Down