💡 Suggests
Views packages suggested for installation by the current project's dependencies. Equivalent to running composer suggests. These packages are not required dependencies, but installing them can enhance the functionality of certain packages (e.g. enabling extra extensions, providing better performance).
📋 Signature
go
func (c *Composer) Suggests() error📥 Parameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
📤 Return value
| Return value | Type | Description |
|---|---|---|
| Sole return value | error | Returned when an error occurs during execution; nil indicates success |
Difference from other commands
This method only returns error rather than (string, error), because suggestion information is typically presented to developers via Composer's standard output for manual decision-making, with no need for further programmatic processing. If you need the output text, use c.Run("suggests") instead.
📝 Example
go
package main
import (
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.New(composer.DefaultOptions())
if err != nil {
log.Fatalf("init Composer failed: %v", err)
}
if err := comp.Suggests(); err != nil {
log.Fatalf("view suggested packages failed: %v", err)
}
}🚀 Advanced
- 📦 To actually install a suggested package: use RequirePackage (
composer require <package>). - 🎁 View donatable packages in the project: use FundPackages (
composer fund). - 🔍 Call this after
composer installorcomposer updateto discover suggestions introduced by new dependencies. - ⚠️
composer suggestswrites to standard output by default; this method discards the output text and only cares whether execution succeeded. To keep the output, use the underlyingRunmethod directly.