Beispiel #1
0
 public static function init($cli)
 {
     register_shutdown_function(['\\Thin\\Bootstrap', 'finish']);
     Timer::start();
     lib('app');
     forever();
     $storage_dir = STORAGE_PATH;
     if (!is_writable(STORAGE_PATH)) {
         die('Please give 0777 right to ' . STORAGE_PATH);
     }
     if (!is_dir(CACHE_PATH)) {
         File::mkdir(CACHE_PATH);
     }
     $dir = APPLICATION_PATH;
     Config::set('app.module.dir', APPLICATION_PATH);
     Config::set('mvc.dir', APPLICATION_PATH);
     Config::set('app.module.dirstorage', $dir . DS . 'storage');
     Config::set('app.module.assets', $dir . DS . 'assets');
     Config::set('app.module.config', $dir . DS . 'config');
     Config::set('dir.raw.store', $storage_dir . DS . 'db');
     Config::set('dir.ardb.store', $storage_dir . DS . 'db');
     Config::set('dir.ephemere', $storage_dir . DS . 'ephemere');
     Config::set('dir.flight.store', $storage_dir . DS . 'flight');
     Config::set('dir.flat.store', $storage_dir . DS . 'flat');
     Config::set('dir.cache.store', $storage_dir . DS . 'cache');
     Config::set('dir.nosql.store', $storage_dir . DS . 'nosql');
     Config::set('dir.module.logs', $storage_dir . DS . 'logs');
     path('module', $dir);
     path('pages', $dir . DS . 'app' . DS . 'pages');
     path('layouts', $dir . DS . 'app' . DS . 'layouts');
     path('store', $storage_dir);
     path('config', Config::get('app.module.config'));
     path('cache', CACHE_PATH);
     loaderProject('entity');
     loaderProject('system');
     Alias::facade('DB', 'EntityProject', 'Thin');
     Alias::facade('System', 'SystemProject', 'Thin');
     System::Db()->firstOrCreate(['name' => SITE_NAME]);
     require_once path('config') . DS . 'application.php';
     if (!$cli) {
         if (fnmatch('*/mytests', $_SERVER['REQUEST_URI'])) {
             self::tests();
         } else {
             self::router();
         }
     }
 }
Beispiel #2
0
function db($db = null)
{
    $db = is_null($db) ? SITE_NAME : $db;
    $i = dyn($db);
    $i->fn('from', function ($table) use($i) {
        return System::Db()->instanciate($i->getNative(), $table);
    });
    return $i;
}
Beispiel #3
0
 public function last($model = false)
 {
     $row = coll($this->run())->last();
     return $model ? loadModel(System::Db()->instanciate($this->db, $this->table), $row) : $row;
 }