Beispiel #1
0
<?php

if (!@(include dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php')) {
    define('AK_ENVIRONMENT', 'development');
    include dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'DEFAULT-config.php';
}
$Dispatcher = new AkDispatcher();
$Dispatcher->dispatch();
Beispiel #2
0
Ak::setStaticVar('AppServer.SessionHandler', new AkAppServerFunctionHandler());
Ak::setStaticVar('AppServer.HeadersHandler', new AkAppServerFunctionHandler());
Ak::setStaticVar('AppServer.PutsHandler', new AkAppServerFunctionHandler());
$_headers = array();
$_puts = '';
$_status = 200;
$counter = 0;
$app = new \MFS\AppServer\Middleware\URLMap\URLMap(array('/' => function ($context = null) {
    global $counter, $_headers, $_puts, $_status;
    $counter++;
    $_puts = '';
    $_status = 200;
    //AkConfig::setOption('Request.remote_ip', AK_REMOTE_IP);
    ob_start();
    $_headers = array('Server', 'Akelos (via AppServer)');
    $Dispatcher = new AkDispatcher();
    $Response = $Dispatcher->dispatchAppServer($context);
    if (count($_headers) == 2) {
        foreach ((array) $Response->getHeaders() as $k => $v) {
            $_headers[] = $k;
            $_headers[] = $v;
        }
    }
    $extra_content = ob_get_clean();
    return array($_status, $_headers, (empty($_puts) && is_string($Response->body) ? $Response->body : $_puts) . $extra_content);
}));
echo "Akelos dev server listening at 127.0.0.1:" . $_SERVER['SERVER_PORT'] . "\n\n";
$handler = new \MFS\AppServer\DaemonicHandler('tcp://127.0.0.1:' . $_SERVER['SERVER_PORT'], 'HTTP');
// serving app
$handler->serve($app);
echo "\nBye!\n";