예제 #1
0
파일: Response.php 프로젝트: Calmacil/GotCm
 /**
  * Renders output
  */
 public function render()
 {
     if (Config::get('debug')) {
         $this->assign('DEBUGBAR_HEADER', Debug::getInstance()->getRenderer()->renderHead());
         $this->assign('DEBUGBAR', Debug::getInstance()->getRenderer()->render());
     }
     $this->assign('CROWNS', $this->getCrownsList());
     $content = $this->environment->render($this->template, $this->template_vars);
     ob_clean();
     ob_start();
     header("HTTP/1.1 " . $this->status);
     header("Content-Type: " . self::TYPE_HTML);
     echo $content;
     ob_end_flush();
 }
예제 #2
0
파일: Db.php 프로젝트: Calmacil/GotCm
 /**
  * Db constructor.
  *
  * Sets up the PDO dsn and establishes connection
  */
 private function __construct()
 {
     $conf = Config::get('db');
     $dsn = sprintf("%s:host=%s;dbname=%s", $conf->dbtype, $conf->host, $conf->dbname);
     Debug::info("Establishing DB connection for {$dsn}");
     try {
         //$pdo = new \PDO($dsn, $conf->user, $conf->password);;
         if (Config::get('debug')) {
             $this->pdo = new TraceablePDO(new \PDO($dsn, $conf->user, $conf->password));
             Debug::info("Adding PDO collector to the dbug");
         } else {
             $this->pdo = new \PDO($dsn, $conf->user, $conf->password);
         }
         $this->pdo->query('SET NAMES utf8');
     } catch (\PDOException $e) {
         Debug::error("Cannot establish database connection:\n{$e->getMessage()}\n{$e->getTraceAsString()}");
     }
 }
예제 #3
0
파일: Debug.php 프로젝트: Calmacil/GotCm
 public static function error($message)
 {
     if (Config::get('debug')) {
         self::$instance->debugBar["messages"]->log('error', $message);
     }
 }
예제 #4
0
파일: index.php 프로젝트: Calmacil/GotCm
 * Time: 11:04
 */
define("ROOT", __DIR__ . '/..');
require_once ROOT . '/vendor/autoload.php';
use Got\Core\Config;
use Got\Core\Debug;
use Got\Core\Router;
use Got\Core\Response;
use Got\Core\Request;
$conf = new Config(ROOT . "/config/config.json");
if (Config::get('debug')) {
    $debug = Debug::getInstance();
    $sql = \Got\Core\Db::getInstance();
    $debug->setupPdoCollector($sql->getConnection());
}
$router = Router::getInstance(ROOT . Config::get('path')->routes_file);
$request = new Request($_SERVER['REQUEST_URI']);
$response = new Response();
try {
    $request->proceed();
    $controller_name = ucfirst($request->getController());
    $action_name = $request->getAction() . 'Action';
    $class = '\\Got\\Action\\' . $controller_name;
    $controller = new $class($request, $response);
    if (!method_exists($controller, $action_name) || !$controller->{$action_name}()) {
        header('HTTP/1.1 404 Not Found');
        echo "BOUH";
        die;
    }
    $response->setTemplate($controller->getTemplate($action_name));
    $response->render();