[code] autoload.txt

    # https://stackoverflow.com/questions/39571391/psr4-auto-load-without-composer

# I am not a fan of Composer for many reasons. 1st reason shared hosting services do not offer composer as a package therefor it makes it harder to deliver low budget applications or simple MVC custom frameworks. Here is a work around that is compliant with PSR4 standards.
# Assuming you add this auto-load method in a file in the root directory and that we are auto-loading classes for everything inside a folder called "src" here is how to archive this.

define('ROOT', dirname(__DIR__));

spl_autoload_register(function ($className)
$fileName = sprintf("%s%ssrc%s%s.php", ROOT, SLASH, SLASH, str_replace("\\", "/", $className));

if (file_exists($fileName))
require ($fileName);
echo "file not found {$fileName}";

# now in every file you should add a namespace and if you have a dependency the use. here is a basic example in
namespace myapp;
use Core\Example;
изменён: 17 октября 2022 г.