How to create a PSR-4 autoloader for my project?

If you are using composer, you do not create the autoloader but let composer do its job and create it for you. The only thing you need to do is create the appropriate configuration on composer.json and execute composer dump-autoload. E.g.: { “autoload”: { “psr-4”: {“App\\”: “src/”} } } By doing the above, if you … Read more

Autoloader for functions

There is no function auto-loader for functions. You have four realistic solutions: Wrap all functions into namespacing classes (context appropriate). So let’s say you have a function called string_get_letters. You could add that to a class called StringFunctions as a static function. So instead of calling string_get_letters(), you’d call StringFunctions::get_letters(). You would then __autoload those … Read more