예제 #1
0
 /**
  * Framework entry point
  *
  * @return void.
  */
 public function dispatch()
 {
     include_once 'action/controller/http/HTTPResponse.php';
     include_once 'action/controller/http/HTTPRequest.php';
     $request = new HTTPRequest();
     $response = new HTTPResponse();
     try {
         $configurator = $this->manager->getConfigurator();
         Registry::put($configurator, '__configurator');
         Registry::put($logger = new Logger($configurator), '__logger');
         $ap = $configurator->getApplicationPath();
         // application path
         $an = $configurator->getApplicationName();
         // application name
         $logger->debug('[Medick] >> version: ' . Medick::getVersion() . ' ready for ' . $an);
         $logger->debug('[Medick] >> Application path ' . $ap);
         $routes_path = $ap . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . $an . '.routes.php';
         include_once $routes_path;
         // load routes
         $logger->debug('[Medick] >> Config File: ' . str_replace($ap, '${' . $an . '}', $configurator->getConfigFile()));
         $logger->debug('[Medick] >> Routes loaded from: ' . str_replace($ap, '${' . $an . '}', $routes_path));
         ActionControllerRouting::recognize($request)->process($request, $response)->dump();
     } catch (Exception $ex) {
         ActionController::process_with_exception($request, $response, $ex)->dump();
         $logger->warn($ex->getMessage());
     }
 }
예제 #2
0
파일: Medick.php 프로젝트: aurelian/medick2
 public static function prepare_application()
 {
     set_error_handler(array(new ErrorHandler(), 'raiseError'));
     Medick::load_framework('context');
     Medick::load_framework('logger');
     Medick::load_framework('plugin');
     Medick::load_framework('action_controller');
     Medick::load_framework('action_view');
     Medick::load_framework('active_record');
 }
예제 #3
0
function setup()
{
    error_reporting(E_ALL | E_STRICT | E_RECOVERABLE_ERROR);
    define('MEDICK_PATH', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..'));
    set_include_path(MEDICK_PATH . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR);
    error_reporting(E_ALL | E_STRICT | E_RECOVERABLE_ERROR);
    require 'medick/Medick.php';
    set_error_handler(array(new ErrorHandler(), 'raiseError'));
    Medick::load_framework('eltest');
}
예제 #4
0
 public function dispatch()
 {
     $request = php_sapi_name() == 'cli' ? new CLIRequest() : new HTTPRequest();
     $response = new HTTPResponse();
     $this->context->logger()->debug(sprintf('medick v.$%s ready to dispatch (took %.3f sec. to boot)', Medick::version(), $this->context->timer()->tick()));
     try {
         Router::recognize($request, $this->context)->process($request, $response)->dump();
         $this->context->logger()->debug(sprintf("\t[%s] done in %.3f sec.", time(), $this->context->timer()->tick(true)));
     } catch (Exception $ex) {
         $message = sprintf('[%s] --> %s in %s line %s', get_class($ex), $ex->getMessage(), $ex->getFile(), $ex->getLine());
         $this->context->logger()->warn(sprintf('Request processing failed after %.3f seconds', $this->context->timer()->tick()));
         $this->context->logger()->warn($message);
         // try to process with exception
         echo php_sapi_name() == 'cli' ? $message : '<pre>' . $message . '</pre>';
         echo php_sapi_name() == 'cli' ? $ex->getTraceAsString() : '<pre style="font-size:85%">' . $ex->getTraceAsString() . '</pre>';
     }
 }
예제 #5
0
 /**
  * Act as an internal constructor.
  * 
  * @param Request request, the request
  * @param Response response, the response
  */
 private function instantiate(Request $request, Response $response)
 {
     // class memebers
     $this->request = $request;
     $this->response = $response;
     $this->params = $request->getParameters();
     $this->logger = Registry::get('__logger');
     $this->injector = Registry::get('__injector');
     $this->config = Registry::get('__configurator');
     $this->session = $request->getSession();
     $this->app_path = $this->injector->getPath('__base');
     $this->template_root = $this->injector->getPath('views') . $this->params['controller'] . DIRECTORY_SEPARATOR;
     $this->template = ActionView::factory('php');
     // register session container if any
     // TODO: this should be moved elsewhere
     if ($this->config->getWebContext()->session !== NULL && $this->config->getWebContext()->session->container !== NULL) {
         // container location.
         $c_location = str_replace('.', DIRECTORY_SEPARATOR, (string) $this->config->getWebContext()->session->container) . '.php';
         include_once $c_location;
         // container class name.
         $e = explode('.', (string) $this->config->getWebContext()->session->container);
         // reflect on container.
         $container = new ReflectionClass(end($e));
         if ($container->implementsInterface('ISessionContainer')) {
             $this->session->setContainer($container->newInstance());
         }
     }
     // predefined variables:
     // TODO: check if we have a / at the end, if not, add one
     $this->template->assign('__base', (string) $this->config->getWebContext()->document_root);
     $this->template->assign('__server', (string) $this->config->getWebContext()->server_name);
     $this->template->assign('__controller', $this->params['controller']);
     $this->template->assign('__version', Medick::getVersion());
     $this->template->assign('__self', $this->__base . $this->request->getRequestUri());
     $this->logger->debug($this->request->toString());
 }
예제 #6
0
<?php

//
// $Id: boot.php 452 2007-08-15 08:06:49Z aurelian $
//
/**
 * It boots a medick application
 *
 * @package medick.core
 */
define('APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
// medick framework path.
define('MEDICK_PATH', join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'vendor', 'medick')));
// rewrite system include path
set_include_path(MEDICK_PATH . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR);
// this should depend on environment
error_reporting(E_ALL | E_STRICT | E_RECOVERABLE_ERROR);
// php 5.1 strict sdandards.
if (version_compare(PHP_VERSION, '5.1.0') > 0) {
    date_default_timezone_set('Europe/Madrid');
}
// load core
require 'medick/Medick.php';
Medick::prepare_application();
 public function setup()
 {
     Medick::load_framework('context');
 }