protected function createSmallApp($eventManager = null) { $serviceManager = new \Owl\Service\Manager(); $router = new Router(); $router->add('/', ['controller' => 'Index', 'action' => 'index']); $serviceManager->set('router', $router); return new Application($serviceManager, $eventManager); }
/** * @return \Owl\Application */ public function bootstrap() { $serviceManager = $this->di; $router = new Router(); $router->add('/', ['module' => 'Api', 'controller' => 'Index', 'action' => 'index']); $router->add('/version', ['module' => 'Api', 'controller' => 'Index', 'action' => 'version']); $router->add('/ping', ['module' => 'Api', 'controller' => 'Index', 'action' => 'ping']); $router->add('/users', ['module' => 'Api', 'controller' => 'User', 'action' => 'list']); $router->add('/users/:id', ['module' => 'Api', 'controller' => 'User', 'action' => 'index']); $router->add('/users/:id', ['module' => 'Api', 'controller' => 'User', 'action' => 'create'], Route::POST); $router->add('/users/:id', ['module' => 'Api', 'controller' => 'User', 'action' => 'delete'], Route::DELETE); $serviceManager->set('router', $router); $driver = new \Owl\DBAl\Driver\Mysql('mysql:host=127.0.0.1;dbname=phalcon-module-skeleton;port=49153', 'root', 'root', array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES "UTF8"')); $connection = new \Owl\DBAL\Connection(['driver' => $driver], $this->eventManager); $serviceManager->set('connection', $connection); $cache = new \Owl\Cache\Driver\Memcached(); $serviceManager->set('cache', $cache); return $this; }
<?php /** * @author Patsura Dmitry http://github.com/ovr <*****@*****.**> */ use Owl\Application; use Owl\Http\Request; use Owl\Router\Route; use Owl\Router\Router; include_once __DIR__ . '/../vendor/autoload.php'; $serviceManager = new Owl\Service\Manager(); $router = new Router(); /** * Frontend */ $router->add('/', ['module' => 'Frontend', 'controller' => 'Index', 'action' => 'index']); /** * Api module - REST API */ $router->add('/api', ['module' => 'Api', 'controller' => 'Index', 'action' => 'index']); $router->add('/api/users', ['module' => 'Api', 'controller' => 'User', 'action' => 'list']); $router->add('/api/users/:id', ['module' => 'Api', 'controller' => 'User', 'action' => 'index']); $router->add('/api/users/:id', ['module' => 'Api', 'controller' => 'User', 'action' => 'create'], Route::POST); $router->add('/api/users/:id', ['module' => 'Api', 'controller' => 'User', 'action' => 'delete'], Route::DELETE); $serviceManager->set('router', $router); $application = new Application($serviceManager); $response = $application->handle(Request::createFromGlobals()); $response->send();
* @author Patsura Dmitry http://github.com/ovr <*****@*****.**> */ use Owl\Application; use Owl\Http\Request; use Owl\Router\Route; use Owl\Router\Router; error_reporting(-1); ini_set('display_errors', 1); include_once __DIR__ . '/../vendor/autoload.php'; $eventManager = new \Owl\Event\Manager(); $profiler = new Owl\Debug\Profiler(); $profiler->setAssetsUri('//assets.owl.local/profiler/min.css'); $profiler->listen($eventManager); $serviceManager = new Owl\Service\Manager(); $router = new Router(); $router->add('/', ['module' => 'Common', 'controller' => 'Index', 'action' => 'index']); $serviceManager->set('router', $router); $driver = new \Owl\DBAl\Driver\Mysql('mysql:host=127.0.0.1;dbname=phalcon-module-skeleton;port=49153', 'root', 'root', array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES "UTF8"')); $connection = new \Owl\DBAL\Connection(['driver' => $driver], $eventManager); $serviceManager->set('connection', $connection); $cache = new \Owl\Cache\Driver\Memcached(); $serviceManager->set('cache', $cache); $view = new \Owl\Mvc\View(); $view->setPath(__DIR__ . '/../app/modules/common/resources/views/'); $serviceManager->set('view', $view); $application = new Application($serviceManager, $eventManager); $application->setErrorHandlerParameters(array('module' => 'Common', 'controller' => 'Index', 'action' => 'error')); $application->setExceptionHandlerParameters(array('module' => 'Common', 'controller' => 'Index', 'action' => 'exception')); $response = $application->handle(Request::createFromGlobals(), new \Owl\Http\Response()); $response = $profiler->setContent($response); $response->send();