Sets the current working directory.
public setWorkingDirectory ( string $cwd ) : self | ||
$cwd | string | The new working directory |
return | self | The current Process instance |
use Symfony\Component\Process\Process; $process = new Process(['ls', '..']); $process->setWorkingDirectory('/var/www'); $process->run(); echo $process->getOutput();
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; $finder = new PhpExecutableFinder(); $phpPath = $finder->find(); $process = new Process([$phpPath, '-v']); $process->setWorkingDirectory('/usr/local/bin'); $process->run(); echo $process->getOutput();This code returns the version of PHP installed in `/usr/local/bin` by pointing to the PHP executable file and using the `-v` flag. In conclusion, the library used in these code examples is Symfony\Component\Process.
public setWorkingDirectory ( string $cwd ) : self | ||
$cwd | string | The new working directory |
return | self | The current Process instance |