Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* @see https://github.com/php-fig/fig-standards/blob/a1a0674a742c9d07c5dd450209fb33b115ee7b40/accepted/PSR-4-autoloader-examples.md#closure-example
*/
spl_autoload_register(static function (string $class): void {
$prefix = 'phpweb\\';
$directory = __DIR__ . '/src/';

$length = strlen($prefix);

if (strncmp($prefix, $class, $length) !== 0) {
return;
}

$relativeClass = substr(
$class,
$length
);

$file = $directory . str_replace('\\', '/', $relativeClass) . '.php';

if (!file_exists($file)) {
return;
}

require $file;
});
2 changes: 1 addition & 1 deletion bin/createNewsEntry
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?php
PHP_SAPI == 'cli' or die("Please run this script using the cli sapi");

require_once __DIR__ . '/../src/News/Entry.php';
require_once __DIR__ . '/../autoload.php';

use phpweb\News\Entry;

Expand Down
2 changes: 1 addition & 1 deletion bin/createReleaseEntry
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?php
PHP_SAPI == 'cli' or die("Please run this script using the cli sapi");

require_once __DIR__ . '/../src/News/Entry.php';
require_once __DIR__ . '/../autoload.php';

use phpweb\News\Entry;

Expand Down
2 changes: 1 addition & 1 deletion include/shared-manual.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $PGI = array(); $SIDEBAR_DATA = '';
// User note display functions
// =============================================================================

require_once __DIR__ . '/../src/UserNotes/Sorter.php';
require_once __DIR__ . '/../autoload.php';
use phpweb\UserNotes\Sorter;

// Print out all user notes for this manual page
Expand Down