coen-hyde / Shanty-Mongo

Shanty Mongo is a mongodb library for the Zend Framework. Its intention is to make working with mongodb documents as natural and as simple as possible. In particular allowing embedded documents to also have custom document classes.
Other
200 stars 52 forks source link

Added dirname function for require_once #82

Closed zhdanov closed 12 years ago

zhdanov commented 12 years ago

Thanks for good library. We use this improvement in their projects. This is necessary for load files without Zend Autoloader.

gwagner commented 12 years ago

Wouldn't it be cleaner to put a $basePath variable in there instead of dirname(__FILE__). That way things are being referenced appropriately and there is no confusion about what the pathing is trying to accomplish.

Secondly there is the argument that re-adding all of the removed require_once statements slows things down for me because i do use auto loading, someone who doesn't use auto loading needs those things there. Zend Framework and other people recommend you remove ALL require_once statements from code because it is a very expensive operation, and your program isn't just skipping over all the require_once statements, it is still processing each one of them and realizing that it already has that thing loaded. We can argue for ever over wether that is a PHP problem or a Programmer problem but the truth of the matter is, on a performance driven site, require_once more than once is a performance drain.

Links to articles about removing redundant require_once statements:

http://framework.zend.com/manual/en/performance.classloading.html http://gogs.info/2008/10/removing-require_once-calls-from-zend-framework/

Using an autoloader (like the classpath autoloader from ZF2) will keep the thing your looking for (people say auto loaders are bad and expensive so why should anyone use one) but lets you keep the element of auto loaded classes to keep your application light and fast.

http://akrabat.com/zend-framework-2/using-zendloaderautoloader/

jwpage commented 12 years ago

Closing this issue, as it's a library built with ZF and its autoloader in mind.

zhdanov commented 12 years ago

Thank you, mans! We think about it.