Exemple #1
0
<?php

/**
 * 入口
 *
 * @author
 * @copyright
 */
use Demo\Bootstrap;
use Phalcon\Http\Response;
use Phalcon\DI\FactoryDefault;
try {
    include __DIR__ . '/../Config/Define.php';
    include SDK_DIR . '/SDK.php';
    include APP_DIR . '/Bootstrap.php';
    $application = new Bootstrap();
    $application->run();
} catch (\Phalcon\Mvc\Dispatcher\Exception $e) {
    $logger = Phalcon\DI\FactoryDefault::getDefault()->get('logger');
    $logger->notice($e->getMessage());
    $response = new Response();
    $response->setStatusCode(404, 'Not Found')->send();
} catch (\Exception $e) {
    $logger = Phalcon\DI\FactoryDefault::getDefault()->get('logger');
    $message = 'Exception: ' . $e->getMessage();
    $logger->error($message);
    $response = new Response();
    $response->setStatusCode(503, debugMode() ? $message : null)->send();
}
Exemple #2
0
/**
 * CLI 入口
 *
 * @author
 * @copyright
 */
use Demo\Bootstrap;
use Phalcon\Http\Response;
use Phalcon\DI\FactoryDefault;
set_time_limit(0);
try {
    include __DIR__ . '/../Config/Define.php';
    include SDK_DIR . '/SDK.php';
    include APP_DIR . '/Bootstrap.php';
    $application = new Bootstrap('CLI');
    $arguments = array();
    foreach ($argv as $k => $arg) {
        if ($k == 1) {
            $arguments['task'] = $arg;
        } elseif ($k == 2) {
            $arguments['action'] = $arg;
        } elseif ($k >= 3) {
            $arguments['params'][] = $arg;
        }
    }
    define('CURRENT_TASK', isset($argv[1]) ? $argv[1] : null);
    define('CURRENT_ACTION', isset($argv[2]) ? $argv[2] : null);
    $application->run($arguments);
} catch (\Exception $e) {
    echo "Exception: " . $e->getMessage() . PHP_EOL;