本文整理汇总了PHP中putenv函数的典型用法代码示例。如果您正苦于以下问题:PHP putenv函数的具体用法?PHP putenv怎么用?PHP putenv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了putenv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run()
{
spl_autoload_register(['Bootstrap', 'autoload']);
putenv('LANG=en_US.UTF-8');
setlocale(LC_CTYPE, 'en_US.UTF-8');
date_default_timezone_set(@date_default_timezone_get());
session_start();
$session = new Session($_SESSION);
$request = new Request($_REQUEST);
$setup = new Setup($request->query_boolean('refresh', false));
$context = new Context($session, $request, $setup);
if ($context->is_api_request()) {
(new Api($context))->apply();
} else {
if ($context->is_info_request()) {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
require __DIR__ . '/pages/info.php';
} else {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
$fallback_html = (new Fallback($context))->get_html();
require __DIR__ . '/pages/index.php';
}
}
}
示例2: testTravisLogger
/**
* It should automatically switch to the travis logger if the
* CONTINUOUS_INTEGRATION environment variable is set.
*/
public function testTravisLogger()
{
putenv('CONTINUOUS_INTEGRATION=1');
$container = new Container(['PhpBench\\Extension\\CoreExtension'], ['path' => 'hello', 'config_path' => '/path/to/phpbench.json']);
$container->init();
$this->assertEquals('travis', $container->getParameter('progress'));
}
示例3: translate
function translate($lang, $test = 0)
{
global $LOCALE_PATH;
putenv("LANGUAGE={$lang}");
bindtextdomain("zarafa", "{$LOCALE_PATH}");
if (STORE_SUPPORTS_UNICODE == false) {
bind_textdomain_codeset('zarafa', "windows-1252");
} else {
bind_textdomain_codeset('zarafa', "utf-8");
}
textdomain('zarafa');
setlocale(LC_ALL, $lang);
$trans_array["Sent Items"] = _("Sent Items");
$trans_array["Outbox"] = _("Outbox");
$trans_array["Deleted Items"] = _("Deleted Items");
$trans_array["Inbox"] = _("Inbox");
$trans_array["Calendar"] = _("Calendar");
$trans_array["Contacts"] = _("Contacts");
$trans_array["Drafts"] = _("Drafts");
$trans_array["Journal"] = _("Journal");
$trans_array["Notes"] = _("Notes");
$trans_array["Tasks"] = _("Tasks");
$trans_array["Junk E-mail"] = _("Junk E-mail");
return $trans_array;
}
示例4: before
function before($route)
{
$lang_mapping = array('fr' => 'fr_FR');
if (!isset($_SESSION['locale'])) {
$locale = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$_SESSION['locale'] = strtolower(substr(chop($locale[0]), 0, 2));
}
$lang = $_SESSION['locale'];
// Convert simple language code into full language code
if (array_key_exists($lang, $lang_mapping)) {
$lang = $lang_mapping[$lang];
}
$lang = "{$lang}.utf8";
$textdomain = "localization";
putenv("LANGUAGE={$lang}");
putenv("LANG={$lang}");
putenv("LC_ALL={$lang}");
putenv("LC_MESSAGES={$lang}");
setlocale(LC_ALL, $lang);
setlocale(LC_CTYPE, $lang);
$locales_dir = dirname(__FILE__) . '/i18n';
bindtextdomain($textdomain, $locales_dir);
bind_textdomain_codeset($textdomain, 'UTF-8');
textdomain($textdomain);
set('locale', $lang);
}
示例5: setLocaleOnCommand
private function setLocaleOnCommand($command)
{
ob_start();
putenv("LC_CTYPE=en_US.UTF-8");
passthru($command);
return ob_get_clean();
}
示例6: startMSS
public static function startMSS()
{
$n = rand(100000000000.0, 1000000000000000.0);
$rand = base_convert($n, 10, 36);
$socketfile = "/tmp/php-connector-{$rand}.sock";
putenv("CPANEL_PHPCONNECT_SOCKET={$socketfile}");
self::$socketfile = $socketfile;
$dir = dirname(__FILE__);
$script = 'startMockSocketServer.php';
$class = 'MockSocketServer.php';
$basedir = realpath("{$dir}/../../..");
$mockserverscript = "{$basedir}/{$script}";
require_once "{$basedir}/{$class}";
if (!file_exists($mockserverscript)) {
self::fail("Mock socket server script '{$mockserverscript}' does not exist");
}
$cmd = "/usr/bin/php -f {$mockserverscript}";
$arg = "socketfile={$socketfile}";
$full_cmd = "nohup {$cmd} {$arg} > /dev/null 2>&1 & echo \$!";
// > /dev/null
$PID = exec($full_cmd);
self::$mockSocketServerPID = $PID;
$lookup = exec("ps -p {$PID} | grep -v 'PID'");
sleep(1);
if (empty($lookup)) {
self::fail('Failed to start mock socket server');
} elseif (!file_exists($socketfile)) {
self::fail('Socket file does not exist: ' . $socketfile);
}
}
示例7: testItReturnsUsefulErrorIfUnknownAndInDevelopment
public function testItReturnsUsefulErrorIfUnknownAndInDevelopment()
{
putenv('APP_ENV=development');
$exception = new RuntimeException('Some message.');
$handled = ExceptionHandler::handleException($exception);
$this->assertEquals(['error' => $exception->getCode(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], $handled);
}
示例8: toEnv
/**
* Makes it so the content is available in getenv()
*/
public function toEnv()
{
$dots = $this->toDots($this->content);
foreach ($dots as $dot_k => $dot_v) {
putenv(sprintf('%s=%s', $dot_k, $dot_v));
}
}
示例9: createApplication
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
putenv('DB_DEFAULT=sqlite_testing');
$app = (require __DIR__ . '/../bootstrap/app.php');
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
return $app;
}
示例10: setLocale
/**
* Sets the current locale code
*/
public function setLocale($locale)
{
//Remove from master until I figure this out
/*if (!$this->isLocaleSupported($locale)) {
throw new Exceptions\LocaleNotSupportedException(
sprintf('Locale %s is not supported', $locale)
);
}*/
try {
$gettextLocale = $locale . "." . $this->encoding;
// All locale functions are updated: LC_COLLATE, LC_CTYPE,
// LC_MONETARY, LC_NUMERIC, LC_TIME and LC_MESSAGES
putenv("LC_ALL={$gettextLocale}");
putenv("LANGUAGE={$gettextLocale}");
setlocale(LC_ALL, $gettextLocale);
// Domain
$this->setDomain($this->domain);
$this->locale = $locale;
$this->session->set($locale);
// Laravel built-in locale
if ($this->configuration->isSyncLaravel()) {
$this->adapter->setLocale($locale);
}
return $this->getLocale();
} catch (\Exception $e) {
$this->locale = $this->configuration->getFallbackLocale();
$exceptionPosition = $e->getFile() . ":" . $e->getLine();
throw new \Exception($exceptionPosition . $e->getMessage());
}
}
示例11: viewvc_utils_wrap_utf8_exec
function viewvc_utils_wrap_utf8_exec($command)
{
ob_start();
putenv("LC_CTYPE=en_US.UTF-8");
passthru($command);
return ob_get_clean();
}
示例12: setEnvVariables
/**
* Set app environment variables
*
* @param string $root
* @return void
*/
public static function setEnvVariables($root = '/')
{
$configs = null;
// Set custom handler to catch errors as exceptions
set_error_handler(create_function('$severity, $message, $file, $line', 'throw new \\ErrorException($message, $severity, $severity, $file, $line);'));
if (file_exists($root . '/.dev.env') && is_readable($root . '/.dev.env')) {
$configs = file_get_contents($root . '/.dev.env');
} else {
if (file_exists($root . '/.dist.env') && is_readable($root . '/.dist.env')) {
$configs = file_get_contents($root . '/.dist.env');
} else {
if (file_exists($root . '/.test.env') && is_readable($root . '/.test.env')) {
$configs = file_get_contents($root . '/.test.env');
} else {
if (file_exists($root . '/.env') && is_readable($root . '/.env')) {
$configs = file_get_contents($root . '/.env');
} else {
throw new NotFoundException('No configuration file found.');
}
}
}
}
if (false === $configs || null !== error_get_last()) {
throw new UnreadableException('Configuration not readable.');
}
// Restore original error handler
restore_error_handler();
$configs = explode("\n", trim($configs));
array_map(function ($config) {
// Remove whitespaces
$config = preg_replace('(\\s+)', '', $config);
// Add as environment variables
putenv($config);
}, $configs);
}
示例13: validateNonNative
protected function validateNonNative()
{
// Check to see if Docker has been exported.
if (!$this->envExported()) {
$this->stdOut->writeln("<comment>Docker environment information not exported. Attempting from PLATFORM_DOCKER_MACHINE_NAME");
if (getenv('PLATFORM_DOCKER_MACHINE_NAME')) {
// Attempt to boot the Docker VM
if (!Machine::start(getenv('PLATFORM_DOCKER_MACHINE_NAME'))) {
$this->stdOut->writeln("<error>Failed to start Docker machine</error>");
exit(1);
}
} else {
$this->stdOut->writeln("<error>You need to start your Docker machine and export the environment information");
exit(1);
}
// Export the Docker VM info on behalf of the user
$this->dockerParams = Machine::getEnv(getenv('PLATFORM_DOCKER_MACHINE_NAME'));
foreach ($this->dockerParams as $key => $value) {
putenv("{$key}={$value}");
}
}
// Give a Docker command a try.
if (!Docker::available()) {
$this->stdOut->writeln("<error>Unable to reach Docker service - try manually exporting environment variables.</error>");
exit(1);
}
}
示例14: loadParamsAndArgs
public function loadParamsAndArgs($self = null, $opts = null, $args = null)
{
parent::loadParamsAndArgs($self, $opts, $args);
if (!empty($this->mOptions['wiki_id'])) {
putenv("SERVER_ID={$this->mOptions['wiki_id']}");
}
}
示例15: logData
/**
* logDiskUsageData
*
* Retrives data and logs it to file
*
* @param string $type type of logging default set to normal but it can be API too.
* @return string $string if type is API returns data as string
* *
*/
public function logData($type = false)
{
$class = __CLASS__;
$settings = Logger::$_settings->{$class};
$timestamp = time();
//get process data here
$ps_args = '-Ao %cpu,%mem,pid,user,comm,args';
putenv('COLUMNS=1000');
$string = shell_exec("ps {$ps_args}");
//$string = explode("\n", trim ($processData));
//get log location
$logdirname = sprintf($this->logdir, date('Y-m-d'));
$logpath = LOG_PATH . $logdirname;
//echo "LOG_PATH : " . $logpath . " \n";
$filename = sprintf($this->logfile, $logdirname, $timestamp);
//echo "FILENAME : " . $filename . " \n";
//great log folder if it doesnt exist
if (!file_exists($logpath)) {
mkdir($logpath, 0777);
}
//read me on encoding array to disk instead
//https://www.safaribooksonline.com/library/view/php-cookbook/1565926811/ch05s08.html
//write out process data to file
LoadUtility::safefilerewrite($filename, $string, "w", true);
if ($type == "api") {
return $string;
} else {
return true;
}
}