So this is a question that has come up many times and most of those times it has come from me. Why don't we use PHP5's __autoload() magic function.
Daniel has expressed a distaste for autoload for reasons noone knows. Why anyone would want to pollute the code with excess includes is beyond me and including files before using them means that some files could be included unnecessarily if not actually used for that particular session.
But I've used autoload successfully in other projects and from the research on the topic, I see absolutely no reason to not be using it. Reviews of autoload are stellar:
http://stackoverflow.com/questions/1408 ... ing-in-php
http://stackoverflow.com/questions/4862 ... d-practice
http://stackoverflow.com/questions/3331 ... erformance
They only say the best practice is to use your own improved autoload function instead of the generic one to better taylor it for your system, which goes without saying anyway. All the other big names seem to be using autoload (interspire, drupal,
Some people believed there was a performance hit with autoload, but all signs point to that being incorrect:
http://www.phpgenious.com/2009/02/php-5 ... ad-method/
One point of autoload is to avoid performance hits by only loading what is needed. Either way, performance hits or gains are minor at best. The main functionality is to allow loading custom classes without needing to worry about manually including them. This allows you to extend and expand existing classes without having to worry about adding each one to the startup.php file and worry about losing those changes during an upgrade.
For OpenCart developers such as myself, this tends to be a pain when creating classes that can be expanded and probably why more people aren't creating classes for some things. The lack of autoload means you have to add additional includes manually to some files to the startup.php or other place.
OpenCart is leading the way in its overall theme and design, but 3rd party developers are constantly hindered by missing major features like autoload.
Hi Qphoria,
I developed some code for the big D a while ago to demonstrate autoload in opencart but after a while he didn't reply any longer.
There is absolutely no reason not to use it as the benefits far out weigh ANY negative you can think of.
Phil.
I developed some code for the big D a while ago to demonstrate autoload in opencart but after a while he didn't reply any longer.
There is absolutely no reason not to use it as the benefits far out weigh ANY negative you can think of.
Phil.
I'm not sure what control would be lost. It simply enables easier classing and subclassing for better 3rd party mods. OpenCart could use a extensible class library for common things like credit card forms, cart and others. The library classes are mostly final classes which means you can't subclass it to add features. So instead we edit the core directly and end up having core mods all over.
Granted that isn't an Autoload issue persay, but when talking about custom classes and libraries, these are things that can be easily added with autoload and just makes for a normal standardized utility part of any platform.
Granted that isn't an Autoload issue persay, but when talking about custom classes and libraries, these are things that can be easily added with autoload and just makes for a normal standardized utility part of any platform.
Surely the whole point of it being open source, is to allow the users to have a contribution. Doesn't have to mean that the main distribution gets changed by the users but makes it easy for users to contribute plugins, extensions and customise things the way they want to.
Web Design Wigan
Football Canvas Prints Powered by OpenCart
Newbie
Who is online
Users browsing this forum: No registered users and 4 guests