Esempio n. 1
0
    include $config->application->appDir . "config/services.php";
    /**
     * Handle the request
     */
    $application = new \Phalcon\Mvc\Application($di);
    // print_r($config->modules->toArray());exit();
    $application->registerModules($config->modules->toArray());
    if (substr($di['request']->getUserAgent(), 0, 11) === 'PHP Yar Rpc') {
        $service = new Yar_Server(new \App\Bootstrap\Service($application));
        $service->handle();
    } else {
        if ($di['request']->getQuery('_method') == 'yar') {
            list($tmp, $module, $controller, $action) = explode('/', $di['request']->getURI());
            $className = "App\\Modules\\" . ucfirst($module) . "\\Controllers\\" . ucfirst($controller) . "Controller";
            include "../app/modules/user/controllers/IndexController.php";
            // $obj = "App\Modules\User\Controllers\IndexController()";
            $service = new Yar_Server();
            $service->handle();
        } else {
            $application->getDI()->set('params', function () use($di) {
                return $di['request']->get();
            });
            echo $application->handle()->getContent();
            $end_time = microtime(true);
            echo "\n<br>\n";
            echo $end_time - $start_time;
        }
    }
} catch (\Phalcon\Exception $e) {
    echo "PhalconException: ", $e->getMessage();
}
Esempio n. 2
0
DEFINE('APP_PATH', __DIR__ . '/..');
DEFINE('TEMPLATE_DIR', APP_PATH . '/app/views/');
date_default_timezone_set('Europe/Kiev');
try {
    //Read the configuration
    $config = new \Phalcon\Config\Adapter\Ini(__DIR__ . '/../app/config/config.ini');
    //Register an autoloader
    $loader = new \Phalcon\Loader();
    //Register some namespaces
    $loader->registerNamespaces($config->library->toArray());
    $loader->registerDirs($config->path->toArray())->register();
    //Create a DI
    $di = new \Phalcon\DI\FactoryDefault();
    $di->set('config', $config);
    //Setting up the view component
    $di->set('view', call_user_func('InitApp::initView'));
    //Start the session the first time when some component request the session service
    $di->set('db', call_user_func('InitApp::initDb'));
    //add dispatcher which handle wrong controllers and actions and other errors
    $di->set('dispatcher', call_user_func('InitApp::initDispatcher'), true);
    //Handle the request
    $application = new \Phalcon\Mvc\Application($di);
    \Phalcon\Tag::setDoctype(\Phalcon\Tag::HTML401_STRICT);
    $application->getDI()->getResponse()->setContentType('text/html', 'UTF-8');
    echo $application->handle()->getContent();
} catch (\Phalcon\Exception $e) {
    error_log("PhalconException: " . $e->getMessage());
} catch (Exception $e) {
    error_log("Exception: " . $e->__toString());
}