if (!is_readable($configPath)) { throw new Exception('Unable to read config from ' . $configPath); } $config = new Phalcon\Config(include_once $configPath); $envConfigPath = CONFIG_DIR . '/server.' . APPLICATION_ENV . '.php'; if (!is_readable($envConfigPath)) { throw new Exception('Unable to read config from ' . $envConfigPath); } $override = new Phalcon\Config(include_once $envConfigPath); $config = $config->merge($override); // Instantiate application & DI $di = new PhalconRest\Di\FactoryDefault(); $app = new PhalconRest\Api($di); // Bootstrap components $bootstrap = new App\Bootstrap(new App\Bootstrap\ServiceBootstrap(), new App\Bootstrap\MiddlewareBootstrap(), new App\Bootstrap\CollectionBootstrap(), new App\Bootstrap\RouteBootstrap(), new App\Bootstrap\AclBootstrap()); $bootstrap->run($app, $di, $config); // Start application $app->handle(); // Set appropriate response value $response = $app->di->getShared(App\Constants\Services::RESPONSE); $returnedValue = $app->getReturnedValue(); if ($returnedValue !== null) { if (is_string($returnedValue)) { $response->setContent($returnedValue); } else { $response->setJsonContent($returnedValue); } } } catch (\Exception $e) { // Handle exceptions $di = $app && $app->di ? $app->di : new PhalconRest\Di\FactoryDefault();
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once '../Application/AutoLoader.php'; $autoLoader = new AutoLoader(realpath(__DIR__ . '/../')); $autoLoader->registerNamespaces(); $bootstrap = new \App\Bootstrap(); $bootstrap->run();