Beispiel #1
0
<?php

use apps\common\migrations\mysql\AccessAssignmentsMigration;
use apps\common\migrations\mysql\AccessItemsMigration;
use apps\common\migrations\mysql\AccessRolesItemsMigration;
use apps\common\migrations\mysql\UsersMigration;
use rock\Rock;
require dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php';
Rock::$app = new Rock();
Rock::$app->language = 'en';
if (!($config = (require dirname(dirname(__DIR__)) . '/common/configs/configs.php'))) {
    die('configs is empty/not found');
}
Rock::$components = $config['components'];
unset($config['components']);
Rock::$config = $config;
\rock\di\Container::registerMulti(Rock::$components);
(new UsersMigration())->up();
(new AccessItemsMigration())->up();
(new AccessRolesItemsMigration())->up();
(new AccessAssignmentsMigration())->up();
Beispiel #2
0
 /**
  * Bootstrap
  *
  * @param array $config
  * @throws \rock\base\BaseException
  */
 public static function bootstrap(array $config)
 {
     Trace::beginProfile(Trace::APP, Trace::TOKEN_APP_RUNTIME);
     static::$components = $config['components'];
     unset($config['components']);
     static::$config = $config;
     Container::registerMulti(static::$components);
     $response = static::$app->response;
     try {
         // Triggered at the beginning
         Event::trigger(static::className(), self::EVENT_BEGIN_APP);
         // Routing
         $route = static::$app->route;
         $route->response = $response;
         $route->run();
     } catch (\Exception $e) {
         ErrorHandler::display($e, Log::CRITICAL, $response);
     }
     //var_dump(Trace::getTime(Trace::APP_TIME));
     Trace::endProfile(Trace::APP, Trace::TOKEN_APP_RUNTIME);
     //var_dump(Trace::get('db.query'), Trace::get(\rock\helpers\Trace::APP));
     // Triggered at the end
     Event::trigger(static::className(), self::EVENT_END_APP);
     $response->send();
 }
Beispiel #3
0
 /**
  * Set config scope
  *
  * @param string $path path to config
  * @param bool $clear clear DIC.
  * @throws RouteException
  * @throws \Exception
  */
 public static function setConfigScope($path, $clear = true)
 {
     $path = Alias::getAlias($path);
     if (!file_exists($path) || !($config = (require $path))) {
         throw new RouteException(RouteException::UNKNOWN_FILE, ['path' => $path]);
     }
     if ($clear) {
         Container::removeAll();
     }
     $components = $config['components'] ?: [];
     if (class_exists('\\rock\\Rock')) {
         unset($config['components']);
         Rock::$components = $components;
         Rock::$config = $config;
     }
     Container::registerMulti($components);
 }