$configPath = CONFIG_DIR . '/default.php'; 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
<?php error_reporting(E_ALL); ini_set('display_errors', 1); define('DS', DIRECTORY_SEPARATOR); define('ROOT', __DIR__); require_once 'vendor' . DS . 'autoload.php'; $bootstrap = new \App\Bootstrap(); $app = $bootstrap->createApplication('\\App\\App'); $app->run($_SERVER);
<?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();