X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=public%2Findex.php;h=5d7a3d7b6510c3754ba63185587ee128861a9e08;hb=7ac195f6bdd98a9d64c58bfc79fd885c2f489c88;hp=6685f6f62c64b43a48ab341c7343b84f46d54348;hpb=d5f0f3216084687f5224e2b4c2768fefca628500;p=zf2.biz%2Fgalerie.git diff --git a/public/index.php b/public/index.php index 6685f6f..5d7a3d7 100644 --- a/public/index.php +++ b/public/index.php @@ -5,15 +5,23 @@ 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(); + } +} + +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