PhpBrew\Tasks\PrepareDirectoryTask::run PHP Method

run() public method

public run ( Build $build = null )
$build PhpBrew\Build
    public function run(Build $build = null)
    {
        $dirs = array();
        $dirs[] = Config::getRoot();
        $dirs[] = Config::getHome();
        $dirs[] = Config::getBuildDir();
        $dirs[] = Config::getDistFileDir();
        $dirs[] = Config::getVariantsDir();
        if ($build) {
            $dirs[] = Config::getInstallPrefix() . DIRECTORY_SEPARATOR . $build->getName();
        }
        foreach ($dirs as $dir) {
            if (!file_exists($dir)) {
                $this->logger->debug("Creating directory {$dir}");
                mkdir($dir, 0755, true);
            }
        }
    }

Usage Example

Example #1
0
 public function execute($version)
 {
     $version = preg_replace('/^php-/', '', $version);
     $releaseList = ReleaseList::getReadyInstance($this->options);
     $releases = $releaseList->getReleases();
     $versionInfo = $releaseList->getVersion($version);
     if (!$versionInfo) {
         throw new Exception("Version {$version} not found.");
     }
     $version = $versionInfo['version'];
     $distUrl = 'http://www.php.net/get/' . $versionInfo['filename'] . '/from/this/mirror';
     if ($mirrorSite = $this->options->mirror) {
         // http://tw1.php.net/distributions/php-5.3.29.tar.bz2
         $distUrl = $mirrorSite . '/distributions/' . $versionInfo['filename'];
     }
     $prepare = new PrepareDirectoryTask($this->logger, $this->options);
     $prepare->run();
     $distFileDir = Config::getDistFileDir();
     $download = new DownloadTask($this->logger, $this->options);
     $targetDir = $download->download($distUrl, $distFileDir, $versionInfo['md5']);
     if (!file_exists($targetDir)) {
         throw new Exception('Download failed.');
     }
     $this->logger->info("Done, please look at: {$targetDir}");
 }
All Usage Examples Of PhpBrew\Tasks\PrepareDirectoryTask::run
PrepareDirectoryTask