Wednesday, December 4, 2013

Zend Skeleton App default ZF2 path?

I'm playing around with the Zend Skeleton Application to see how useful it will be to build an application in the future. I got it all installed correctly using a combination of git and composer and everything is working fine...until I try and update the autoloader.

As it turns out, composer seems to have installed the zend framework in a different area than it was expected in the Zend Skeleton Application default configuration.

The default autoloader file init_autoloader.php looks like this
$zf2Path = false;


if (is_dir('vendor/ZF2/library')) {
    $zf2Path = 'vendor/ZF2/library';
} elseif (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');
}

The composer install put everything in vendor/zendframework/zendframework/library and not in vendor/ZF2/library. A quick little update like below and I was all set.

$zf2Path = false;


if (is_dir(vendor/zendframework/zendframework/library')) {
    $zf2Path = 'vendor/zendframework/zendframework/library';
} elseif (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');
}