X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=public%2Findex.php;h=f347d342f402e9e4cf42dddfca16b5a074656d7a;hb=b1ed9cf58083c48409f4d33923657eb8dc0ec70d;hp=6685f6f62c64b43a48ab341c7343b84f46d54348;hpb=a530a988873f4c5d6eb7bf36601b9a42d3908428;p=zf2.biz%2Fgalerie.git diff --git a/public/index.php b/public/index.php index 6685f6f..f347d34 100644 --- a/public/index.php +++ b/public/index.php @@ -5,15 +5,27 @@ use Zend\Mvc\Service\ServiceManagerConfiguration; chdir(dirname(__DIR__)); -// Allow using an alternative copy of ZF2 -if (getenv('ZF2_PATH')) { - require_once getenv('ZF2_PATH') . '/Zend/Loader/AutoloaderFactory.php'; - AutoloaderFactory::factory(); +// Composer autoloading +if (file_exists('vendor/autoload.php')) { + $loader = include 'vendor/autoload.php'; } -// Composer autoloading -if (!include_once('vendor/autoload.php')) { - throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?'); +// Support for ZF2_PATH environment variable or git submodule +if ($zf2Path = getenv('ZF2_PATH') ?: (is_dir('vendor/ZF2/library') ? 'vendor/ZF2/library' : false)) { + if (isset($loader)) { + $loader->add('Zend', $zf2Path . '/Zend'); + } else { + include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; + AutoloaderFactory::factory(array( + 'Zend\Loader\StandardAutoloader' => array( + 'autoregister_zf' => true + ) + )); + } +} + +if (!class_exists('Zend\Loader\AutoloaderFactory')) { + throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); } // Get application stack configuration