/** * 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); }
<?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();
<?php error_reporting(-1); if (version_compare(PHP_VERSION, '5.4.0', '<')) { die('need to use PHP version 5.4.x or greater'); } require dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php'; defined('ROCK_DEBUG') or define('ROCK_DEBUG', true); defined('DS') or define('DS', DIRECTORY_SEPARATOR); \rock\Rock::$app = new \rock\Rock(); // catch error \rock\exception\ErrorHandler::register(); $config = (require dirname(__DIR__) . '/configs/configs.php'); // bootstrap application \rock\Rock::bootstrap($config);