Development

Changeset 2805

You must first sign up to be able to contribute.

Changeset 2805

Show
Ignore:
Timestamp:
11/25/06 08:14:46 (2 years ago)
Author:
fabien
Message:

lime: removed dependance on PEAR System class (closes #1119)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/lime/lib/lime.php

    r2761 r2805  
    362362    if (!is_executable($this->php_cli)) 
    363363    { 
    364       // search in PATH 
    365       require_once('System.php'); 
    366       foreach (array('php5', 'php') as $php_cli) 
    367       { 
    368         if ($this->php_cli = System::which($php_cli)) 
    369         { 
    370           break; 
    371         } 
    372       } 
    373  
    374       if (!is_executable($this->php_cli)) 
    375       { 
    376         throw new Exception("Unable to find PHP executable."); 
    377       } 
     364      $this->php_cli = $this->find_php_cli(); 
    378365    } 
    379366 
    380367    $this->output = $output_instance ? $output_instance : new lime_output(); 
     368  } 
     369 
     370  protected function find_php_cli() 
     371  { 
     372    $path = getenv('PATH') ? getenv('PATH') : getenv('Path'); 
     373    $exe_suffixes = OS_WINDOWS ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : array('.exe', '.bat', '.cmd', '.com')) : array(); 
     374    foreach (array('php5', 'php') as $php_cli) 
     375    { 
     376      foreach ($exe_suffixes as $suffix) 
     377      { 
     378        foreach (explode(PATH_SEPARATOR, $path) as $dir) 
     379        { 
     380          $file = $dir.DIRECTORY_SEPARATOR.$php_cli.$suffix; 
     381          if (is_executable($file)) 
     382          { 
     383            return $file; 
     384          } 
     385        } 
     386      } 
     387    } 
     388 
     389    throw new Exception("Unable to find PHP executable."); 
    381390  } 
    382391