apprentice (77) [Avatar] Offline
#1
Why does Rob usually use APPLICATION_PATH instead of the reserved php constant dirname(_FILE_), in the Bootstrapper's basePath line?

________________________________________________________________

How Zend Quickstart tutorial does things.

[pre]
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Default',
'basePath' => dirname(__FILE__),
));
return $autoloader;
}
[/pre]
________________________________________________________________

How Rob usually does things.

[pre]
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
return $moduleLoader;
}
[/pre]
________________________________________________________________
jnunez (18) [Avatar] Offline
#2
Re: Why does Rob usually use APPLICATION_PATH instead of dirname(_FILE_)?
In the index.php, he sets the constant APPLICATION_PATH with the results of the function dirname() and parameter __FILE__. The use to APPLICATION_PATH is faster throughout the rest of the code and if you ever needed to change your application's path it would take a single change from the index.php.
apprentice (77) [Avatar] Offline
#3
Re: Why does Rob usually use APPLICATION_PATH instead of dirname(_FILE_)?
Thanks for the explanation jnunez it makes sense now smilie
akrabat (479) [Avatar] Offline
#4
Re: Why does Rob use APPLICATION_PATH instead of dirname(_FILE_)? - [SOLVED
As jnunez says. I'm a big fan of constants and defines as they avoid having to do the same work more than once if you ever need to change them.

Regards,

Rob...