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


PHP putenv函数代码示例

本文整理汇总了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';
         }
     }
 }
开发者ID:arter97,项目名称:h5ai,代码行数:26,代码来源:class-bootstrap.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'));
 }
开发者ID:dantleech,项目名称:phpbench,代码行数:11,代码来源:CoreExtensionTest.php

示例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;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:25,代码来源:exec.zarafa7.foldersnames.php

示例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);
}
开发者ID:sheelarajeshkumar,项目名称:torclient_ynh,代码行数:26,代码来源:config.php

示例5: setLocaleOnCommand

 private function setLocaleOnCommand($command)
 {
     ob_start();
     putenv("LC_CTYPE=en_US.UTF-8");
     passthru($command);
     return ob_get_clean();
 }
开发者ID:ansarbek,项目名称:tuleap,代码行数:7,代码来源:ViewVCProxy.class.php

示例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);
     }
 }
开发者ID:shirone,项目名称:publicapi-php,代码行数:30,代码来源:LiveapiTest.php

示例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);
 }
开发者ID:fuzz-productions,项目名称:image-resizer,代码行数:7,代码来源:ExceptionHandlerTest.php

示例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));
     }
 }
开发者ID:null9beta,项目名称:Vars,代码行数:10,代码来源:TransformerTrait.php

示例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;
 }
开发者ID:nguyensuper,项目名称:TBEx-CMS,代码行数:12,代码来源:TestCase.php

示例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());
     }
 }
开发者ID:rpsimao,项目名称:laravel-gettext,代码行数:33,代码来源:Gettext.php

示例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();
}
开发者ID:rinodung,项目名称:tuleap,代码行数:7,代码来源:viewvc_utils.php

示例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);
 }
开发者ID:jabranr,项目名称:lassi,代码行数:41,代码来源:Util.php

示例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);
     }
 }
开发者ID:pjcdawkins,项目名称:platform-docker,代码行数:27,代码来源:DockerCommand.php

示例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']}");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:task_runner.php

示例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;
     }
 }
开发者ID:javinc,项目名称:loadavg,代码行数:39,代码来源:log.Process.php


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