예제 #1
0
<?php

/**
 * 入口
 *
 * @author
 * @copyright
 */
use Test\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) {
    FactoryDefault::getDefault()->get('logger')->notice($e->getMessage());
    $response = new Response();
    $response->setStatusCode(404, 'Not Found')->send();
} catch (\Exception $e) {
    $message = 'Exception: ' . $e->getMessage();
    FactoryDefault::getDefault()->get('logger')->error($message);
    $response = new Response();
    $response->setStatusCode(503, debugMode() ? $message : null)->send();
}
예제 #2
0
 * CLI 入口
 *
 * @author
 * @copyright
 */
use Test\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;
    exit(-1);
}