🖥️ CheckPlatformReqs — Check platform requirements
🔍
CheckPlatformReqschecks whether the current runtime environment satisfies the PHP extensions and platform requirements declared incomposer.json, equivalent to runningcomposer check-platform-reqs, commonly used for pre-deployment environment validation.
📋 Signature
go
func (c *Composer) CheckPlatformReqs() (string, error)📥 Parameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
📤 Return value
| Return value | Type | Description |
|---|---|---|
| First return value | string | Text output of the platform requirements check result |
| Second return value | error | Returned when an error occurs during execution; nil on success |
📝 Example
go
package main
import (
"fmt"
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.NewComposer()
if err != nil {
log.Fatalf("failed to create Composer instance: %v", err)
}
output, err := comp.CheckPlatformReqs()
if err != nil {
log.Fatalf("failed to check platform requirements: %v", err)
}
fmt.Println("Platform requirements check result:")
fmt.Println(output)
}🚀 Advanced
- 📋 To get results in
jsonortextformat for programmatic parsing, useCheckPlatformReqsWithFormat(format). - 🧪 Calling this method in a deployment script can surface missing PHP extensions (e.g.
ext-mbstring,ext-pdo) before installing dependencies. - ⚠️ When platform requirements are not satisfied, Composer exits with a non-zero exit code and
Runreturns anerror; use this to abort the deployment flow. - 🔗 Use in combination with
Validate(): first useValidate()to check thecomposer.jsonformat, then use this method to validate the runtime environment.