Ejemplo n.º 1
0
<?php

/**
 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.
 */
chdir(dirname(__DIR__));
//we activate full error reporting for our sample, to ease support
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
    return false;
}
// Setup autoloading
require 'vendor/autoload.php';
$container = (require 'config/container.php');
$app = new \Zend\Stratigility\MiddlewarePipe();
//CargoUI route
$app->pipe('/', function (\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, callable $next = null) use($container) {
    if ($request->getUri()->getPath() === "/") {
        /** @var $cargoUi \Codeliner\CargoUI\Main::class */
        $cargoUi = $container->get(\Codeliner\CargoUI\Main::class);
        return $cargoUi($request, $response, $next);
    }
    return $next($request, $response);
});
$cargoBackend = $container->get('Codeliner\\CargoBackend');
$app->pipe('/api', $cargoBackend);
$server = \Zend\Diactoros\Server::createServer($app, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
$server->listen();
Ejemplo n.º 2
0
<?php

/*
 * This file is part of the prooph/no-mvc.
 * (c) 2014-2015 prooph software GmbH <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 * 
 * Date: 5/28/15 - 11:26 PM
 */
/**
 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.
 */
chdir(dirname(__DIR__));
// Setup autoloading
require 'vendor/autoload.php';
$smConfig = new \Zend\ServiceManager\Config(require 'config/services.php');
$serviceManager = new \ProophExample\NoMvc\Infrastructure\Container\Zf2InteropContainer($smConfig);
$serviceManager->setService('config', require 'config/application.config.php');
$app = new \Zend\Stratigility\MiddlewarePipe();
$dispatcher = \Zend\Stratigility\Dispatch\MiddlewareDispatch::factory(require 'config/routes.php');
$dispatcher->setContainer($serviceManager);
$app->pipe('/', $dispatcher);
// Run the server!
$server = \Zend\Diactoros\Server::createServer($app, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
$server->listen();