🐘 HasPHP
Checks whether PHP is available on the system.
When to Use
Use this when you need to confirm PHP is present before installing Composer or running any PHP-dependent command. ✅
Signature
go
func HasPHP() boolParameters
| Parameter | Type | Description |
|---|---|---|
| None | — | Package-level function, takes no parameters |
Return Value
bool:truemeans PHP is available;falsemeans it was not found.
Example
go
package main
import (
"fmt"
"github.com/scagogogo/composer-skills/pkg/installer"
)
func main() {
if installer.HasPHP() {
fmt.Println("PHP is ready")
} else {
fmt.Println("PHP is missing; install it first")
}
}Advanced
- Detection paths: first checks
phpinPATH, then/usr/bin/php,/usr/local/bin/php, and/opt/homebrew/bin/php. 🔍 - If missing and you want to auto-install, use
InstallPHP. 🛠️ - If you need the version number, use
GetPHPVersion. 🔖 - This is the precondition check inside
Installer.InstallandInstallWithProgress. 🔗