/** * @return Nette\Loaders\RobotLoader */ public function createRobotLoader() { if ($this->robotLoader === NULL) { $loader = parent::createRobotLoader(); $loader->addDirectory($this->parameters['packagesDir']); $this->robotLoader = $loader; } return $this->robotLoader; }
/** * @param Configurator * @return void */ protected function setupRobotLoader(Configurator $configurator) { if ($this->options->getRobotLoaderOptions() !== NULL && $this->options->getRobotLoaderOptions()->isEnabled()) { $robotLoader = $configurator->createRobotLoader(); foreach ($this->options->getRobotLoaderOptions()->getDirectories() as $directory) { $robotLoader->addDirectory($directory); } $robotLoader->register(); } }
/** * @return Configurator */ protected function createConfigurator() { $this->defineConstants(); $configurator = new Configurator(); $configurator->setDebugMode($this->debugger); $configurator->enableDebugger(LOG_DIR); Debugger::$strictMode = FALSE; $configurator->setTempDirectory(TEMP_DIR); $configurator->createRobotLoader()->addDirectory(APP_DIR)->register(); return $configurator; }
/** * @return RobotLoader */ public function createRobotLoader() { $params = $this->getParameters(); $loader = parent::createRobotLoader(); $loader->addDirectory($params['appDir']); if ($this->isConsoleMode()) { $loader->addDirectory($params['binDir']); $loader->addDirectory($params['migrationsDir']); } if ($this->isTestMode()) { $loader->addDirectory($params['testsDir']); } return $loader; }
/** * Creates RobotLoader and unregisters Nette's original inject extension. * * @param Configurator $configurator * @param string $robotLoaderDir */ public static function bootstrapTweak(Configurator $configurator, $robotLoaderDir) { self::$staticRobotLoader = $configurator->createRobotLoader()->addDirectory($robotLoaderDir)->register(); unset($configurator->defaultExtensions['inject']); }
<?php namespace NetteAddons; use Nette\Configurator; // Load Nette Framework or autoloader generated by Composer require __DIR__ . '/../vendor/autoload.php'; $configurator = new Configurator(); // Enable Nette Debugger for error visualisation & logging //$configurator->setDebugMode(TRUE); $configurator->enableDebugger(__DIR__ . '/../log'); // Specify folder for cache $configurator->setTempDirectory(__DIR__ . '/../temp'); // Enable RobotLoader - this will load all classes automatically $configurator->createRobotLoader()->addDirectory(__DIR__)->register(); // Create Dependency Injection container from config.neon file $configurator->addConfig(__DIR__ . '/config/config.neon'); $configurator->addConfig(__DIR__ . '/config/config.local.neon'); $container = $configurator->createContainer(); return $container;
/** * @return RobotLoader */ public function createRobotLoader() { $params = $this->getParameters(); $loader = parent::createRobotLoader(); $loader->addDirectory($params['appDir']); $loader->addDirectory($params['binDir']); $loader->addDirectory($params['appDir'] . '/../migrations'); $loader->addDirectory($params['appDir'] . '/../tests'); $loader->addDirectory($params['libsDir'] . '/others'); return $loader; }
private function prepareRobotLoader(Configurator $configurator) { $robotLoader = $configurator->createRobotLoader(); foreach ($this->robotLoadedPaths as $path) { $robotLoader->addDirectory($path); } $robotLoader->register(); }
protected function createConfigurator() { $configurator = new Configurator(); // Fix incorrectly initialized appDir $configurator->addParameters(['appDir' => $this->appDir]); // Add root dir $configurator->addParameters(['rootDir' => $this->rootDir]); // Add temp dir $configurator->addParameters(['tempDir' => $this->tempDir]); $configurator->setTempDirectory($this->tempDir); if ($this->debug && $this->isDebugger()) { $configurator->setDebugMode($this->debuggers); } else { $configurator->setDebugMode(FALSE); } if ($this->enableLog) { $configurator->enableDebugger($this->tempDir . '/log', $this->debugEmails); } // Load app $loader = $configurator->createRobotLoader()->addDirectory($this->appDir); // Load additional paths specified in index.php foreach ($this->loaderPaths as $path) { $loader->addDirectory($path); } $loader->register(); return $configurator; }
require __DIR__ . '/shortcuts.php'; require __DIR__ . '/../vendor/autoload.php'; class_alias(Logger::class, 'Nette\\Diagnostics\\Logger'); $configurator = new Configurator(); $debugMode = FALSE; $environmentFile = __DIR__ . '/local/environment'; if (file_exists($environmentFile)) { $environment = file_get_contents($environmentFile); $debugMode = $environment === 'production' ? FALSE : TRUE; } else { $environment = 'production'; } $environment = Strings::trim(Strings::lower($environment)); $debugSwitchFile = __DIR__ . '/local/debug'; if (file_exists($debugSwitchFile)) { $debugMode = Strings::trim(mb_strtolower(file_get_contents($debugSwitchFile))) === 'true' ? TRUE : FALSE; } // Enable Nette Debugger for error visualisation & logging $configurator->setDebugMode($debugMode); $configurator->enableDebugger(__DIR__ . '/../log'); // Specify folder for cache $configurator->setTempDirectory(__DIR__ . '/../temp'); // Enable RobotLoader - this will load all classes automatically $robotLoader = $configurator->createRobotLoader()->addDirectory(__DIR__)->addDirectory(__DIR__ . '/../libs')->register(); // Create Dependency Injection container from config.neon file $configurator->addConfig(__DIR__ . '/config/config.neon'); $localConfig = __DIR__ . '/local/config.local.neon'; if (file_exists($localConfig)) { $configurator->addConfig($localConfig); } return $configurator;