當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Config::getVersionEtcPath方法代碼示例

本文整理匯總了PHP中PhpBrew\Config::getVersionEtcPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Config::getVersionEtcPath方法的具體用法?PHP Config::getVersionEtcPath怎麽用?PHP Config::getVersionEtcPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PhpBrew\Config的用法示例。


在下文中一共展示了Config::getVersionEtcPath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setup

 public function setup($options)
 {
     $phpConfigFile = $options->production ? 'php.ini-production' : 'php.ini-development';
     $this->logger->info("---> Copying config file for " . $options->production ? 'production' : 'development');
     if (file_exists($phpConfigFile)) {
         $this->logger->info("Found config file: {$phpConfigFile}");
         $version = Config::getCurrentPhpName();
         if (!file_exists(Config::getVersionEtcPath($version))) {
             $dir = Config::getVersionEtcPath($version);
             $this->logger->debug("Creating config directory");
             mkdir($dir, 0755, true);
         }
         $targetConfigPath = Config::getVersionEtcPath($version) . DIRECTORY_SEPARATOR . 'php.ini';
         if (file_exists($targetConfigPath)) {
             $this->logger->notice("{$targetConfigPath} exists, do not overwrite.");
         } else {
             // TODO: Move this to PhpConfigPatchTask
             // move config file to target location
             copy($phpConfigFile, $targetConfigPath);
             // replace current timezone
             $timezone = ini_get('date.timezone');
             $pharReadonly = ini_get('phar.readonly');
             if ($timezone || $pharReadonly) {
                 // patch default config
                 $content = file_get_contents($targetConfigPath);
                 if ($timezone) {
                     $this->logger->info("---> Found date.timezone, patch config timezone with {$timezone}");
                     $content = preg_replace('/^date.timezone\\s*=\\s*.*/im', "date.timezone = {$timezone}", $content);
                 }
                 if (!$pharReadonly) {
                     $this->logger->info("---> Disable phar.readonly option.");
                     $content = preg_replace('/^phar.readonly\\s*=\\s*.*/im', "phar.readonly = 0", $content);
                 }
                 file_put_contents($targetConfigPath, $content);
             }
         }
     }
 }
開發者ID:WebDevJL,項目名稱:phpbrew,代碼行數:38,代碼來源:DefaultConfigTask.php

示例2: execute


//.........這裏部分代碼省略.........
        foreach ($variantInfo['enabled_variants'] as $name => $value) {
            $build->enableVariant($name, $value);
        }
        foreach ($variantInfo['disabled_variants'] as $name => $value) {
            $build->disableVariant($name);
            if ($build->hasVariant($name)) {
                $this->logger->warn("Removing variant {$name} since we've disabled it from command.");
                $build->removeVariant($name);
            }
        }
        $build->setExtraOptions($variantInfo['extra_options']);
        if ($options->clean) {
            $clean = new CleanTask($this->logger);
            $clean->cleanByVersion($version);
        }
        $buildLogFile = Config::getVersionBuildLogPath($version);
        $configure = new \PhpBrew\Tasks\ConfigureTask($this->logger);
        $configure->configure($build, $this->options);
        $buildTask = new BuildTask($this->logger);
        $buildTask->setLogPath($buildLogFile);
        $buildTask->build($build, $this->options);
        if ($options->{'test'}) {
            $test = new TestTask($this->logger);
            $test->setLogPath($buildLogFile);
            $test->test($build, $this->options);
        }
        $install = new InstallTask($this->logger);
        $install->setLogPath($buildLogFile);
        $install->install($build, $this->options);
        if ($options->{'post-clean'}) {
            $clean = new CleanTask($this->logger);
            $clean->cleanByVersion($version);
        }
        /** POST INSTALLATION **/
        $dsym = new DSymTask($this->logger);
        $dsym->patch($build, $this->options);
        // copy php-fpm config
        $this->logger->info("---> Creating php-fpm.conf");
        $phpFpmConfigPath = "sapi/fpm/php-fpm.conf";
        $phpFpmTargetConfigPath = Config::getVersionEtcPath($version) . DIRECTORY_SEPARATOR . 'php-fpm.conf';
        if (file_exists($phpFpmConfigPath)) {
            if (!file_exists($phpFpmTargetConfigPath)) {
                copy($phpFpmConfigPath, $phpFpmTargetConfigPath);
            } else {
                $this->logger->notice("Found existing {$phpFpmTargetConfigPath}.");
            }
        }
        $phpConfigPath = $options->production ? 'php.ini-production' : 'php.ini-development';
        $this->logger->info("---> Copying {$phpConfigPath} ");
        if (file_exists($phpConfigPath)) {
            $targetConfigPath = Config::getVersionEtcPath($version) . DIRECTORY_SEPARATOR . 'php.ini';
            if (file_exists($targetConfigPath)) {
                $this->logger->notice("Found existing {$targetConfigPath}.");
            } else {
                // TODO: Move this to PhpConfigPatchTask
                // move config file to target location
                copy($phpConfigPath, $targetConfigPath);
                // replace current timezone
                $timezone = ini_get('date.timezone');
                $pharReadonly = ini_get('phar.readonly');
                if ($timezone || $pharReadonly) {
                    // patch default config
                    $content = file_get_contents($targetConfigPath);
                    if ($timezone) {
                        $this->logger->info("---> Found date.timezone, patch config timezone with {$timezone}");
                        $content = preg_replace('/^date.timezone\\s*=\\s*.*/im', "date.timezone = {$timezone}", $content);
                    }
                    if (!$pharReadonly) {
                        $this->logger->info("---> Disable phar.readonly option.");
                        $content = preg_replace('/^phar.readonly\\s*=\\s*.*/im', "phar.readonly = 0", $content);
                    }
                    file_put_contents($targetConfigPath, $content);
                }
            }
        }
        $this->logger->info("Initializing pear config...");
        $home = Config::getPhpbrewHome();
        @mkdir("{$home}/tmp/pear/temp", 0755, true);
        @mkdir("{$home}/tmp/pear/cache_dir", 0755, true);
        @mkdir("{$home}/tmp/pear/download_dir", 0755, true);
        system("pear config-set temp_dir {$home}/tmp/pear/temp");
        system("pear config-set cache_dir {$home}/tmp/pear/cache_dir");
        system("pear config-set download_dir {$home}/tmp/pear/download_dir");
        $this->logger->info("Enabling pear auto-discover...");
        system("pear config-set auto_discover 1");
        $this->logger->debug("Source directory: " . $targetDir);
        $this->logger->info("Congratulations! Now you have PHP with {$version}.");
        echo <<<EOT
To use the newly built PHP, try the line(s) below:

    \$ phpbrew use {$version}

Or you can use switch command to switch your default php version to {$version}:

    \$ phpbrew switch {$version}

Enjoy!

EOT;
    }
開發者ID:bensb,項目名稱:phpbrew,代碼行數:101,代碼來源:InstallCommand.php


注:本文中的PhpBrew\Config::getVersionEtcPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。