本文整理汇总了PHP中Environment::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::setName方法的具体用法?PHP Environment::setName怎么用?PHP Environment::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::setName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
// db error - dibiDriverException
define('OPERATION_FAILED', 'Operation could NOT be performed. Please, try again in few seconds');
// 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 LIBS_DIR . '/Nette/loader.php';
require LIBS_DIR . '/Custom/utils.php';
require LIBS_DIR . '/Custom/MultiConfig.php';
// set console mode according to host name
if (Environment::isConsole()) {
if (php_uname('n') === 'CIKINOTAS') {
$name = 'console_dev';
} else {
$name = 'console_prod';
}
Environment::setName($name);
}
//$config = Environment::loadConfig();
$config = MultiConfig::load();
//$loader = new RobotLoader();
//$loader->autoRebuild = true; // pokud nenajdu třídu, mám se znovusestavit?
//dump($loader);
//die();
// debug only
//Environment::setMode(Environment::PRODUCTION, 1 );
// Step 2: Configure environment
// 2a) enable Debug for better exception and error visualisation
Debug::$strictMode = TRUE;
// determines whether to consider all errors as fatal
// todo: v novsej verzii sa predava uz iba adresar, nie nazov suboru
Debug::enable('213.215.67.27, 127.0.0.1', Environment::getVariable('logDir') . '/err.log', 'matula.m@gmail.com');
示例2: createService
<h1>Nette\Environment config test</h1>
<pre>
<?php
require_once '../../Nette/loader.php';
/*use Nette\Debug;*/
/*use Nette\Environment;*/
class Factory
{
static function createService($options)
{
Debug::dump(__METHOD__);
Debug::dump($options);
return (object) NULL;
}
}
echo "Loading config:\n";
Environment::setName(Environment::PRODUCTION);
Environment::loadConfig('config.ini');
echo "Variable foo:\n";
Debug::dump(Environment::getVariable('foo'));
echo "Constant HELLO_WORLD:\n";
Debug::dump(constant('HELLO_WORLD'));
echo "php.ini config:\n";
Debug::dump(Environment::getConfig('php'));
echo "Database config:\n";
Debug::dump(Environment::getConfig('database'));
echo "is production mode?\n";
Debug::dump(Environment::isProduction());
示例3: die
<?php
/**
* DataGrid example application bootstrap file.
*
* @author Roman Sklenář
* @package DataGrid\Example
*/
// Step 1: Load Nette Framework
if (!is_dir(LIBS_DIR . '/Nette')) {
die("Extract Nette Framework to library directory '" . realpath(LIBS_DIR) . "'.");
}
require_once LIBS_DIR . '/Nette/loader.php';
// Step 2: Configure environment
/** 2a) load configuration from config.ini file */
Environment::setName(Environment::DEVELOPMENT);
$config = Environment::loadConfig();
/** 2b) check if needed directories are writable */
if (!is_writable(Environment::getVariable('tempDir'))) {
die("Make directory '" . realpath(Environment::getVariable('tempDir')) . "' writable!");
}
if (!is_writable(Environment::getVariable('logDir'))) {
die("Make directory '" . realpath(Environment::getVariable('logDir')) . "' writable!");
}
/** 2c) Setup Nette\Debug for better exception and error visualisation */
//Debug::$productionMode = $_SERVER['REMOTE_ADDR'] !== '127.0.0.1'; // admin's computer IP
$mode = !Environment::isProduction() && !Environment::getHttpRequest()->isAjax() ? Debug::DEVELOPMENT : Debug::PRODUCTION;
Debug::enable($mode, NULL);
Debug::$strictMode = TRUE;
Debug::$showLocation = TRUE;
/** 2d) enable RobotLoader - this allows load all classes automatically */
示例4: catch
<h1>Nette\Environment name test</h1>
<pre>
<?php
require_once '../../Nette/loader.php';
/*use Nette\Debug;*/
/*use Nette\Environment;*/
//define('ENVIRONMENT', 'lab');
echo "Name:\n";
Debug::dump(Environment::getName());
try {
echo "Setting name:\n";
Environment::setName('lab2');
Debug::dump(Environment::getName());
} catch (Exception $e) {
echo get_class($e), ': ', $e->getMessage(), "\n\n";
}