You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.
I'm working on a new project and I'm trying out Swiftlet - I like it very much so far. One problem I encountered, however, is the autoloader.
/Swiftlet/App.php has an autoload function which is registered using spl_autoload_register. But it seems the autoload function makes no attempt to check if the file exists. So if I run some code using class_exists, the autoload function will attempt to load the file, resulting in an error.
Another problem related to this is being able to register multiple autoloaders. In another issue - #40 - you suggest copying and modifying the autoload function from /Swiftlet/App.php and updating the call to spl_autoload_register to use the new function. But considering the documentation for spl_autoload_register states:
If there must be multiple autoload functions, spl_autoload_register() allows for this. It effectively creates a queue of autoload functions, and runs through each of them in the order they are defined.
I think it might be better to allow users to register their own autoloaders to run in combination with Swiftlet's. And for that to work properly, it seems there needs to be a check for the existence of the file before requireing it. I've done this myself by extending Swiftlet/App and overriding the autoload function to add: if (file_exists($file)) require $file;
The text was updated successfully, but these errors were encountered:
I'm working on a new project and I'm trying out Swiftlet - I like it very much so far. One problem I encountered, however, is the autoloader.
/Swiftlet/App.php
has anautoload
function which is registered usingspl_autoload_register
. But it seems the autoload function makes no attempt to check if the file exists. So if I run some code usingclass_exists
, the autoload function will attempt to load the file, resulting in an error.Another problem related to this is being able to register multiple autoloaders. In another issue - #40 - you suggest copying and modifying the autoload function from
/Swiftlet/App.php
and updating the call tospl_autoload_register
to use the new function. But considering the documentation forspl_autoload_register
states:I think it might be better to allow users to register their own autoloaders to run in combination with Swiftlet's. And for that to work properly, it seems there needs to be a check for the existence of the file before
require
ing it. I've done this myself by extendingSwiftlet/App
and overriding the autoload function to add:if (file_exists($file)) require $file;
The text was updated successfully, but these errors were encountered: