/** * @param string error log directory * @param string administrator email * @return void */ public function enableDebugger($logDirectory = NULL, $email = NULL) { Nette\Diagnostics\Debugger::$strictMode = TRUE; Nette\Diagnostics\Debugger::enable($this->parameters['productionMode'], $logDirectory, $email); }
$options = $_SERVER['argv']; array_shift($options); $config = new Config(); $config->processCliOptions($options); $generator = new Generator($config); // Help if ($config->isHelpRequested()) { echo $generator->colorize($generator->getHeader()); echo $generator->colorize($config->getHelp()); die; } // Prepare configuration $config->prepare(); if ($config->debug) { Debugger::$onFatalError = array(); Debugger::enable(Debugger::DEVELOPMENT, false); } $generator->output($generator->getHeader()); // Check for update (only in production mode) if ($config->updateCheck && !$config->debug) { ini_set('default_socket_timeout', 5); $latestVersion = @file_get_contents('http://pear.apigen.org/rest/r/apigen/latest.txt'); if (false !== $latestVersion && version_compare(trim($latestVersion), Generator::VERSION, '>')) { $generator->output(sprintf("New version @header@%s@c available\n\n", $latestVersion)); } } // Scan if (count($config->source) > 1) { $generator->output(sprintf("Scanning\n @value@%s@c\n", implode("\n ", $config->source))); } else { $generator->output(sprintf("Scanning @value@%s@c\n", $config->source[0]));
<?php /** * My Application bootstrap file. */ use Nette\Diagnostics\Debugger, Nette\Application\Routers\Route; // Load Nette Framework require LIBS_DIR . '/Nette/loader.php'; // Enable Nette Debugger for error visualisation & logging Debugger::$logDirectory = __DIR__ . '/../log'; Debugger::$strictMode = TRUE; Debugger::enable(); // Configure application $configurator = new Nette\Config\Configurator(); $configurator->setTempDirectory(__DIR__ . '/../temp'); // Enable RobotLoader - this will load all classes automatically $configurator->createRobotLoader()->addDirectory(APP_DIR)->addDirectory(LIBS_DIR)->register(); // Create Dependency Injection container from config.neon file $configurator->addConfig(__DIR__ . '/config/config.neon'); $container = $configurator->createContainer(); // Opens already started session if ($container->session->exists()) { $container->session->start(); } // Setup router $router = $container->router; if (MobileDetection::isMobile()) { // mobile routing $router[] = new Route('index.php', 'Mobile:Homepage:default', Route::ONE_WAY); $router[] = new Route('<presenter>/<action>[/<id>]', 'Mobile:Homepage:default'); } else {
/** * Nette\Diagnostics\Debugger::enable() shortcut. */ function debug() { Debugger::$strictMode = TRUE; Debugger::enable(Debugger::DEVELOPMENT); }
<?php use Nette\Configurator, Nette\Diagnostics\Debugger, Nette\Application\Routers\Route; // Nette Framework require_once LIBS_DIR . '/Nette/loader.php'; // Enable Nette Debugger for error visualization & logging Debugger::$strictMode = TRUE; Debugger::enable(Debugger::DETECT, LOG_DIR, '*****@*****.**'); // Load configuration from config.neon file $configurator = new Configurator(); $configurator->loadConfig(dirname(__FILE__) . '/config.neon'); // Setup router $router = $configurator->container->router; if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) { // Jednosměrná routa $router[] = new Route('index.php', 'Default:', Route::ONE_WAY); // Dvousměrná routa s cool-url tvarem $router[] = new Route('<presenter>/<action>[/<id [0-9]+>][/<id2 [0-9]+>]', 'Default:'); } else { $router[] = new SimpleRouter('Default:default'); } // Configure and run the application! $application = $configurator->container->application; $application->errorPresenter = 'Error'; if ($configurator->container->params['productionMode']) { $application->catchExceptions = TRUE; } $application->run();
<?php /** * My Application bootstrap file. * * @copyright Copyright (c) 2009 John Doe * @package MyApplication */ // Step 1: Load Nette Framework // this allows load Nette Framework classes automatically so that // you don't have to litter your code with 'require' statements require __DIR__ . '/../../vendor/autoload.php'; // Step 2: Configure environment // 2a) enable Nette\Debug for better exception and error visualisation \Nette\Diagnostics\Debugger::enable(\Nette\Diagnostics\Debugger::DEVELOPMENT, APP_DIR . "/log"); // 2b) load configuration from config.ini file //Nette\Environment::loadConfig(); // Step 3: Configure application // 3a) get and setup a front controller $application = Nette\Environment::getApplication(); $application->errorPresenter = 'Error'; //$application->catchExceptions = TRUE; $loader = new \Nette\Loaders\RobotLoader(); $loader->setCacheStorage(Nette\Environment::getContext()->cacheStorage); $loader->addDirectory(APP_DIR); $loader->register(); use Nette\Application\Routers\Route; // Step 4: Setup application router $router = $application->getRouter(); $router[] = new Route('index.php', array('presenter' => 'Download', 'action' => 'default'), Route::ONE_WAY); $router[] = new Route('<presenter>/<action>/<id>', array('presenter' => 'Download', 'action' => 'default', 'id' => NULL));
<?php namespace NJLogParser; require_once __DIR__ . "/libs/nette.min.php"; require_once __DIR__ . "/libs/Curl.php"; require_once __DIR__ . "/libs/CurlResponse.php"; require_once __DIR__ . "/libs/Parser.php"; use Nette\Diagnostics\Debugger; set_time_limit(0); Debugger::enable(Debugger::DEVELOPMENT, __DIR__); Debugger::timer(); /************************************ SQLite *************************************/ /*if (file_exists(__DIR__."/db.sqlite")) { copy(__DIR__."/db.sqlite", __DIR__."/backup/".date("Y-m-d_H-i-s-").substr(microtime(TRUE)-time(), 2, 4).".sqlite"); } $connection = new \Nette\Database\Connection('sqlite:' . __DIR__ . '/db.sqlite'); \Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/db.structure.sqlite.sql'); /************************************ MySQL *************************************/ $connection = new \Nette\Database\Connection('mysql:host=localhost;dbname=njlogparser', 'nette', 'nette'); \Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/db.structure.mysql.sql'); if (!defined('STDIN')) { echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>' . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Nette Jabber Log Parser</title></head><body><code><pre>'; } $parser = new Parser($connection); $parser->originalDataDir = __DIR__ . "/data"; //$parser->debug = TRUE; $factory = new \Nette\Http\RequestFactory(); $factory->setEncoding('UTF-8'); $req = $factory->createHttpRequest(); if (($date = $req->getQuery('date', NULL)) || ($date = isset($argv[1]) ? $argv[1] : NULL)) {
<?php define('LIBS_DIR', __DIR__ . '/../libs'); require_once LIBS_DIR . '/Nette/loader.php'; require_once LIBS_DIR . '/dump.php'; use Nette\Diagnostics\Debugger as Debug; use Nette\Environment; use Nette\Loaders\RobotLoader; Debug::enable(false); Debug::$strictMode = true; Environment::setVariable('tempDir', __DIR__ . '/tmp'); $r = new RobotLoader(); $r->setCacheStorage(Environment::getContext()->cacheStorage); $r->addDirectory(LIBS_DIR); $r->addDirectory(__DIR__ . '/cases'); $r->register(); require_once __DIR__ . '/TestCase.php';
/** * @param string error log directory * @param string administrator email */ public function enableDebugger($logDirectory = NULL, $email = NULL) { $debugMode = $this->isDebugMode(); if (isset($this->parameters['debugModeLogin']['name']) && isset($this->parameters['debugModeLogin']['password'])) { if (isset($_GET['debugMode'])) { if ($_GET['debugMode']) { if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] !== $this->parameters['debugModeLogin']['name'] || $_SERVER['PHP_AUTH_PW'] !== $this->parameters['debugModeLogin']['password']) { header('WWW-Authenticate: Basic realm="Debug mode"'); header('HTTP/1.0 401 Unauthorized'); exit; } } } if (isset($this->parameters['debugModeLogin']['name']) && isset($this->parameters['debugModeLogin']['password']) && isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER'] === $this->parameters['debugModeLogin']['name'] && $_SERVER['PHP_AUTH_PW'] === $this->parameters['debugModeLogin']['password']) { $debugMode = TRUE; } } Debugger::$strictMode = TRUE; Debugger::enable(!$debugMode, $logDirectory ?: $this->parameters['logDir'], $email); }
public function __construct($netteLoader) { require $netteLoader; Debugger::enable(Debugger::DEVELOPMENT); }
<?php if (!($loader = (include __DIR__ . '/../../vendor/autoload.php'))) { echo 'Install Nette Tester using `composer update --dev`'; exit(1); } $loader->add('LibretteTests', __DIR__ . '/../'); \Nette\Diagnostics\Debugger::enable(\Nette\Diagnostics\Debugger::DEVELOPMENT, __DIR__ . '/../tmp/'); Tester\Environment::setup(); date_default_timezone_set('Europe/Prague'); define('TEMP_DIR', __DIR__ . '/../tmp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid())); Tester\Helpers::purge(TEMP_DIR); $_SERVER = array_intersect_key($_SERVER, array_flip(array('PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv'))); $_SERVER['REQUEST_TIME'] = 1234567890; $_ENV = $_GET = $_POST = array(); function run(Tester\TestCase $testCase) { $testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL); }
/** * Tatami bootstrap file. * * @copyright Copyright (c) 2011 Martin Bazik * @package Tatami */ use Nette\Diagnostics\Debugger, Nette\Application\Routers\SimpleRouter, Nette\Application\Routers\Route, Tatami\Events\Event; // Load Nette Framework $params['libsDir'] = __DIR__ . '/../libs'; require $params['libsDir'] . '/Nette/loader.php'; $params['logDir'] = __DIR__ . '/../log'; Debugger::$logDirectory = $params['logDir']; Debugger::$strictMode = TRUE; //Debugger::$productionMode = false; Debugger::enable('188.167.64.246'); $params['assetsDir'] = __DIR__ . '/assets'; $configurator = new Nette\Configurator(); $configurator->container->params += $params; $configurator->container->params['tempDir'] = __DIR__ . '/../temp'; //check if generated config exists try { $configurator->loadConfig($params['appDir'] . '/config/config.neon'); } catch (\Nette\FileNotFoundException $e) { //if not, read the default config and install application $configurator->loadConfig($params['appDir'] . '/config/config-default.neon'); } $router = new \Tatami\Routing\TatamiRouter(); $configurator->getContainer()->addService('router', $router); $application = $configurator->container->application; $application->errorPresenter = 'Error';
use FileDownloader\FDTools; use FileDownloader\FileDownload; use Nette\Diagnostics\Debugger; use Nette\Forms\Form; // Generate form $f = new Form("upload-form"); $f->getElementPrototype()->id = "frm"; $f->setMethod("GET"); $f->addSelect("speed", "Speed", array(1 => "1byte/s", 50 => "50bytes/s", 512 => "512bytes/s", 1 * FDTools::KILOBYTE => "1kb/s", 5 * FDTools::KILOBYTE => "5kb/s", 20 * FDTools::KILOBYTE => "20kb/s", 32 * FDTools::KILOBYTE => "32kb/s", 50 * FDTools::KILOBYTE => "50kb/s", 64 * FDTools::KILOBYTE => "64kb/s", 100 * FDTools::KILOBYTE => "100kb/s", 128 * FDTools::KILOBYTE => "128kb/s", 200 * FDTools::KILOBYTE => "200kb/s", 256 * FDTools::KILOBYTE => "256kb/s", 300 * FDTools::KILOBYTE => "300kb/s", 512 * FDTools::KILOBYTE => "512kb/s", 1 * FDTools::MEGABYTE => "1mb/s", 2 * FDTools::MEGABYTE => "2mb/s", 5 * FDTools::MEGABYTE => "5mb/s", 10 * FDTools::MEGABYTE => "10mb/s", 0 => "Unlimited")); $f->addText("filename", "Filename")->addRule(Form::FILLED, "You must fill name!"); $f->addSelect("size", "Size", array(1 => "1MB", 4 => "4MB", 8 => "8MB", 16 => "16MB", 32 => "32MB", 64 => "64MB", 128 => "128MB", 256 => "256MB", 512 => "512MB")); $f->addSelect("log", "Log called events?", array(0 => "No", 1 => "Yes (may cause CPU load)")); $f->addSubmit("download", "Download!"); $f->setDefaults(array("speed" => 50, "filename" => "Some horrible file name - ěščřžýáíé.bin", "size" => 8, "log" => 1)); if ($f->isSubmitted() and $f->isValid()) { Debugger::enable(Debugger::PRODUCTION); // Log errors to file! $val = $f->getValues(); $location = dirname(__FILE__) . "/cache/test-" . $val["size"] . "MB.tmp"; if (!file_exists($location)) { generateFile($location, $val["size"] * 1024); } /* Interface with getters and setters */ $file = new FileDownload(); $file->sourceFile = $location; $file->transferFileName = $val["filename"]; $file->speedLimit = (int) $val["speed"]; //$file->mimeType = $val["mimeType"]; /* Functions defined in example_library.php */ if ($val["log"] == 1) { $file->onBeforeDownloaderStarts[] = "onBeforeDownloaderStarts";
// Load libs define('VENDORS_DIR', __DIR__ . "/../vendors"); define('NELLA_FRAMEWORK_DIR', __DIR__ . "/../Nella"); require_once VENDORS_DIR . "/Nette/loader.php"; require_once NELLA_FRAMEWORK_DIR . "/SplClassLoader.php"; SplClassLoader::getInstance(array( 'Nella' => __DIR__ . "/../Nella", 'NellaTests' => __DIR__, 'Doctrine' => VENDORS_DIR . "/Doctrine", 'Symfony' => VENDORS_DIR . "/Symfony" ))->register(); // Setup Nette profiler Debugger::$strictMode = TRUE; Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . "/log"); // Init DI Container $container = new \Nette\DI\Container; $container->params = array( 'appDir' => __DIR__, 'libsDir' => VENDORS_DIR, 'tempDir' => __DIR__ . "/temp", 'uploadDir' => __DIR__ . "/uploads", 'storageDir' => "%tempDir", 'imageCacheDir' => "%tempDir", 'productionMode' => FALSE, 'consoleMode' => TRUE, 'flashes' => array( 'success' => "success", 'error' => "error",
<?php use Nette\Diagnostics\Debugger, Nette\Loaders\RobotLoader, Nette\Caching\Storages\FileStorage; if (@(!(include __DIR__ . '/../vendor/autoload.php'))) { echo 'Install Nette Tester using `composer update --dev`'; exit(1); } define('LOG_DIR', __DIR__ . '/log'); define('TEMP_DIR', __DIR__ . '/temp'); define('MOCKS_DIR', __DIR__ . '/Mocks'); define('ELERIUM_DIR', __DIR__ . '/../Elerium'); Debugger::$consoleMode = TRUE; Debugger::$strictMode = TRUE; Debugger::enable(Debugger::DEVELOPMENT, LOG_DIR); $loader = new RobotLoader(); $loader->addDirectory(ELERIUM_DIR); $loader->setCacheStorage(new FileStorage(TEMP_DIR)); $loader->register();
<?php define('LIBS_DIR', __DIR__ . '/../libs'); define('TMP_DIR', __DIR__ . '/../temp'); require LIBS_DIR . '/autoload.php'; // Configure application $configurator = new Nette\Config\Configurator(); // Enable RobotLoader - this will load all classes automatically $configurator->setTempDirectory(TMP_DIR); $configurator->createRobotLoader()->addDirectory(__DIR__ . '/../src')->register(); \Nette\Diagnostics\Debugger::enable(false); \Nette\Diagnostics\Debugger::$strictMode = true;