On Fri, Feb 22, 2013 at 2:59 PM, mpalourdio <[email protected]> wrote:
> :)
>
> In fact, in init_autoload.php, the code is ambigious for me. When reading
> theses lines
>
> if (getenv('ZF2_PATH')) {           // Support for ZF2_PATH environment
> variable or git submodule
>     $zf2Path = getenv('ZF2_PATH');
> } elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value
>     $zf2Path = get_cfg_var('zf2_path');
> } elseif (is_dir('vendor/ZF2/library')) {
>     $zf2Path = 'vendor/ZF2/library';
> }
>
> I would expect the first 'if' to be the definitive rule for zf2 file
> location, no ? I mean, what is the point to make this first test, not to use
> it later if zf2 files are located too in both 'vendor' and ZF2_PATH?
>
> For me, the most logical would be : if getenv('ZF2_PATH'), then, use this
> path and this one only no ?
>
> Maybe there's something that's not really clear for me...

It's actually doing exactly what you think it should -- the elseif
statements will not be executed if the first matches.

To explain further:

If you look closely at init_autoloader.php, those conditions are
really only for the case when Composer is not used. They go from most
specific condition to least -- in other words, configuration over
convention.

So, if you have specified a ZF2_PATH environment variable, that trumps
any other way the path might be set. You would typically specify this
in your vhost definition, your .htaccess, or potentially in your
fastcgi script. In other words, this will be very specific to your
environment. If this matches, no other conditions are looked at.

If it fails, it looks to see if you have a zf2_path configuration
variable set. get_cfg_var() checks in the php.ini configuration. As an
example, Zend Server will set this for the ZF2 package it installs by
default, which allows you to use ZF2 projects without having ZF2 _in_
your project. This is less specific than a ZF2_PATH env variable, as
php.ini settings will typically affect all vhosts. Again, if this
matches, we won't look anywhere else.

Finally, if all else fails, it checks to see if we have a
vendor/ZF2/library/ directory. This is the default location for doing
a git submodules for ZF2 in the skeleton application, if you're going
to use that route.

If one of these sets $zf2Path, we'll setup autoloading using the
library from that location.

Again, however: if you installed via Composer, all of these will fail,
and we don't have to do any more work, really -- other than make sure
the ZF2 autoloader factory exists.



-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to