当前位置: 首页>>代码示例>>PHP>>正文


PHP Environment::setName方法代码示例

本文整理汇总了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');
开发者ID:radypala,项目名称:maga-website,代码行数:31,代码来源:bootstrap.php

示例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());
开发者ID:vrana,项目名称:nette,代码行数:29,代码来源:test.config.php

示例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 */
开发者ID:romansklenar,项目名称:nette-datagrid,代码行数:31,代码来源:bootstrap.php

示例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";
}
开发者ID:vrana,项目名称:nette,代码行数:17,代码来源:test.name.php


注:本文中的Environment::setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。