Skip to content

Commit befe5c9

Browse files
committed
[minor] Add a sample fancy usage of PhpSwitcher
1 parent ec73542 commit befe5c9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ PS C:\>
133133

134134
You can use the `Remove-PhpFromSwitcher` to remove a PHP installation from the PHP Switcher, `Move-PhpSwitcher` to change the directory where `php.exe` will be visible in (`C:\Dev\PHP` in the example above), and `Remove-PhpSwitcher` to remove the PHP Switcher.
135135

136+
You can do many fancy stuff with PHP Switcher. For example, to download and enable the `redis` PHP extension for all the PHP versions, you can write something like this:
137+
138+
```powershell
139+
$phpSwitcher = Get-PhpSwitcher
140+
$phpSwitcher.Targets.Keys | ForEach-Object {
141+
Write-Host -Object "Installing for $_... " -NoNewline
142+
try {
143+
Install-PhpExtension -Path $phpSwitcher.Targets[$_] redis
144+
Write-Host -Object 'done.' -ForegroundColor Green
145+
} catch {
146+
Write-Host -Object $_ -ForegroundColor Red
147+
}
148+
}
149+
```
150+
136151
If you want to let **Apache** work with PHP, you have to add the `LoadModule` directive to the Apache configuration file, which should point to the appropriate DLL.
137152
For instance, with PHP 5.6 it is
138153

0 commit comments

Comments
 (0)