Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Autoload and Loading other Classes

posted by ecropolis 8 years ago

Specifically I'm trying to load Amazon Web Services PHP-SDK http://aws.amazon.com/sdkforphp/ Seems the autoload() tries to load the call for the class even though I've already loaded it. Thus my application dies. I tried adding the logic if (!class_exists($class_name)) { ... that doesn't work. I tried adding some logic to the autoloader function to just go ahead and filter it out path it right and autoload but it doesn't work; I think because I'm not loading a class file but rather another initialization type of file because it has its own string of dependencies.

I know this isn't really a Flourish issue but any direction you could give on the topic of loading up other classes would be very appreciated.

Warren

I had a similar problem with the CssMin library. It kept loading up a twitter-async (EpiTwitter) file because of it's own autoloader that was registered with spl_autoload_register(). So I commented this out and that stopped the problem since my own autoload() had no need for its own (I put CssMin all into one file CssMin.php and I only call for class CssMin anyway).

In production, you should consider not auto-loading anything and get your includes ready.

Are you on PHP 5.3? If you are, spl_autoload_register() works a little bit differently (but nicer as in namespaces).

posted by audvare 8 years ago