示例#1
0
function getServiceLocator()
{
    $config = Zend\Config\Factory::fromFile(findParentPath('config') . "/module.config.php");
    $serviceManagerConfig = new \Zend\ServiceManager\Config($config['service_manager']);
    $serviceManager = new \Zend\ServiceManager\ServiceManager($serviceManagerConfig);
    $serviceManager->setService('config', $config);
    return $serviceManager;
}
示例#2
0
<?php

$vendorDir = findParentPath('vendor');
if (file_exists($file = $vendorDir . '/autoload.php')) {
    require_once $file;
} else {
    throw new \RuntimeException("Composer autoload not found");
}
function findParentPath($path)
{
    $dir = __DIR__;
    $previousDir = '.';
    while (!is_dir($dir . '/' . $path)) {
        $dir = dirname($dir);
        if ($previousDir === $dir) {
            return false;
        }
        $previousDir = $dir;
    }
    return $dir . '/' . $path;
}