<?php // Load local configuration $config = (include_once './config/app.php'); // What will we use in our application? use Duality\App; // Create application container $app = new App(dirname(__FILE__), $config); // Get server and request from globals $server = $app->call('server'); $request = $server->getRequestFromGlobals($_SERVER, $_REQUEST); // Validate request. This is a Web application. if (!$request) { die('HTTP request not found!' . PHP_EOL); } // Set server request $server->setRequest($request); // Set demo routes $server->setHome('\\Demo\\Controller\\Welcome@doIndex'); // Tell server to execute services $server->listen();
// Setup configuration file $config_path = './config/app.php'; if (!file_exists($config_path)) { die('Error: configuration file not found: ' . $config_path . PHP_EOL); } // Load local configuration $config = (include_once $config_path); // Validate configuration if (!is_array($config)) { die('Error: configuration file does not return array.' . PHP_EOL); } // What will we use in our application? use Duality\Service\SSH; use Duality\App; // Create application container $app = new App(dirname(__FILE__), $config); // Reload database schema $config = $app->call('db')->getSchemaConfig(); $app->call('db')->reloadFromConfig($config); // Get the commander $cmd = $app->call('cmd'); // Add the database responders $cmd->addResponder('/^db:create$/i', function () use($app) { return $app->call('db')->createFromConfig(); }); $cmd->addResponder('/^db:update$/i', function () use($app) { return $app->call('db')->updateFromConfig(); }); $cmd->addResponder('/^db:seed$/i', function () use($app) { return $app->call('db')->seedFromConfig(); });