Skip to content
Snippets Groups Projects
Select Git revision
  • 431bbc990b7a7dbf23f7fc7afa10f0babd33e57b
  • master default protected
  • release-1.3.10
  • popover-bootstrap-3.4
  • zf-3.x
  • 3.0.9
  • 3.0.8
  • 1.3.10
  • 3.0.7
  • 3.0.6
  • 3.0.5
  • 3.0.4
  • 3.0.3
  • 3.0.2
  • 3.0.1
  • 3.0.0
  • 1.3.9
  • 1.3.8
  • 1.3.7
  • 1.3.6
  • 1.3.5
  • 1.3.4
  • 1.3.3
  • 1.3.2
  • 1.3.1
25 results

Bootstrap.php

Blame
  • Forked from lib / unicaen / auth
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Bootstrap.php 2.42 KiB
    <?php
    namespace UnicaenAppTest;
    
    use Zend\Loader\AutoloaderFactory;
    use Zend\Mvc\Service\ServiceManagerConfig;
    use Zend\ServiceManager\ServiceManager;
    use RuntimeException;
    
    error_reporting(E_ALL | E_STRICT);
    chdir(__DIR__);
    
    /**
     * Test bootstrap, for setting up autoloading
     */
    class Bootstrap
    {
        protected static $serviceManager;
    
        public static function init()
        {
            $zf2ModulePaths = [dirname(dirname(__DIR__))];
            if (($path = static::findParentPath('vendor'))) {
                $zf2ModulePaths[] = $path;
            }
            if (($path = static::findParentPath('module')) !== $zf2ModulePaths[0]) {
                $zf2ModulePaths[] = $path;
            }
            $zf2ModulePaths[] = __DIR__;
    
            static::initAutoloader();
    
            static::$serviceManager = new ServiceManager([]);
        }
    
        public static function getServiceManager()
        {
            return static::$serviceManager;
        }
    
        protected static function initAutoloader()
        {
            $vendorPath = static::findParentPath('vendor');
    
            if (is_readable($vendorPath . '/autoload.php')) {
                include $vendorPath . '/autoload.php';
                return;
            }
    
            $zf2Path = getenv('ZF2_PATH');
            if (!$zf2Path) {
                if (defined('ZF2_PATH')) {
                    $zf2Path = ZF2_PATH;
                } elseif (is_dir($vendorPath . '/ZF2/library')) {
                    $zf2Path = $vendorPath . '/ZF2/library';
                } elseif (is_dir($vendorPath . '/zendframework/zendframework/library')) {
                    $zf2Path = $vendorPath . '/zendframework/zendframework/library';
                }
            }
    
            if (!$zf2Path) {
                throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
            }
    
            include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
            AutoloaderFactory::factory([
                'Zend\Loader\StandardAutoloader' => [
                    'autoregister_zf' => true,
                    'namespaces' => [
                        __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__,
                    ],