Skip to content

⬆️ OutdatedPackages

Shows all outdated packages in the project along with available updates, equivalent to composer outdated.

When to use

  • 🔄 Periodically check whether dependencies have new versions available to upgrade.
  • 📈 Monitor technical debt in CI and output an outdated package report.
  • 🔒 Assess the impact scope before upgrading.

Signature

go
func (c *Composer) OutdatedPackages() (string, error)

Parameters

None.

Return value

ValueTypeDescription
OutputstringThe text output of the outdated packages list
ErrorerrorReturned when an error occurs while fetching the outdated packages list

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("init failed: %v", err)
    }

    output, err := comp.OutdatedPackages()
    if err != nil {
        log.Fatalf("failed to get outdated packages list: %v", err)
    }
    fmt.Println("Outdated packages:", output)
}

Advanced

Structured results

When you need programmatic processing, use GetOutdatedInfo instead. It runs composer outdated --format=json and parses it into *OutdatedResult, containing Installed/Latest/LatestStatus for each package.

Narrowing the scope

  • OutdatedPackagesDirect(): only look at dependencies directly declared in composer.json.
  • ShowOutdatedWithFormat(format): specify the output format (e.g. json).
  • OutdatedWithOptions(options) / OutdatedWithFormat(format): more flexible variants.
  • GetOutdatedInfo: structured outdated package information.
  • BumpPackages: upgrade packages to the latest version within their constraints.

Released under the MIT License