🔒 CheckPlatformWithLock
Checks whether the current system satisfies the platform requirements locked in composer.lock, returning a structured list of platform information.
When to use
In production deployment, the composer.lock is usually the source of truth; you need to confirm that the runtime environment meets the exact PHP version and extension requirements recorded in the lock file.
Signature
go
func (c *Composer) CheckPlatformWithLock() ([]PlatformInfo, error)Parameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters; it reads the current project's composer.lock directly |
Return value
[]PlatformInfo: Slice of platform requirement info parsed fromcomposer.lockerror: Returned when executingcomposer check-platform --lock --format=jsonor parsing fails
Example
go
package main
import (
"fmt"
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.New(composer.DefaultOptions())
if err != nil {
log.Fatal(err)
}
platforms, err := comp.CheckPlatformWithLock()
if err != nil {
log.Fatalf("failed to check lock file platform requirements: %v", err)
}
for _, p := range platforms {
if !p.Available {
fmt.Printf("Warning: %s %s requirement not satisfied\n", p.Name, p.Required)
}
}
}Advanced
- This method runs
composer check-platform --lock --format=jsoninternally and only reads theLockfield - The non-lock version is CheckPlatform
- To validate lock file sync in one go, use it together with CheckStructured