🏗️ GetProjectSummary
Combines multiple information sources and returns a complete summary of the project, including basic info, dependency counts, outdated package counts, security vulnerability counts, and Composer and PHP versions.
When to use
Use this when you need to generate a "health report" or dashboard data for a project. It internally aggregates multiple calls such as ReadComposerJson, GetProjectDependencies, GetOutdatedInfo, GetAuditInfo, and GetVersion; it is the highest-level convenience method.
Signature
go
func (c *Composer) GetProjectSummary() (*ProjectSummary, error)Parameters
This method takes no parameters.
Return value
| Return value | Type | Description |
|---|---|---|
| First return value | *ProjectSummary | Project summary struct |
| Second return value | error | Always nil (each internal step is fault-tolerant) |
ProjectSummary fields: Name, Description, Type, License, DirectDependencyCount, DevDependencyCount, TotalInstalledCount, OutdatedCount, VulnerabilityCount, ComposerVersion, PHPVersion.
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.Fatalf("Initialization failed: %v", err)
}
summary, err := comp.GetProjectSummary()
if err != nil {
log.Fatalf("Failed to get project summary: %v", err)
}
fmt.Printf("Project: %s\n", summary.Name)
fmt.Printf("Outdated packages: %d, Security vulnerabilities: %d\n",
summary.OutdatedCount, summary.VulnerabilityCount)
fmt.Printf("Composer: %s, PHP: %s\n",
summary.ComposerVersion, summary.PHPVersion)
}Advanced
- If you only need dependency counts and package names, use the lighter GetProjectDependencies.
- To query outdated package details separately, use
GetOutdatedInfo; to query vulnerabilities separately, useGetAuditInfo. - Because it aggregates multiple command calls, it takes a long time on large projects; caching the result is recommended.