Skip to content

🚫 Prohibit

Shows packages that are prohibited from installation by the current platform requirements. Equivalent to running composer prohibit.

When to use

Use this when you need to understand the restrictions imposed by the current PHP version and extension configuration on package installation — i.e. which packages are excluded because they do not satisfy platform constraints. It is commonly used in root-cause analysis for "why was a certain package not installed".

Signature

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

Parameters

This method takes no parameters.

Return value

Return valueTypeDescription
First return valuestringThe list of prohibited packages (text)
Second return valueerrorReturned when the query 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.Fatalf("init failed: %v", err)
	}

	output, err := comp.Prohibit()
	if err != nil {
		log.Fatalf("query prohibited packages failed: %v", err)
	}
	fmt.Println("Packages prohibited by platform requirements:")
	fmt.Println(output)
}

Advanced

  • To specify the output format, use ProhibitWithFormat(format), e.g. "json".
  • For custom options, use ProhibitWithOptions(options).
  • To check whether platform requirements are satisfied, use CheckPlatformReqs().

Released under the MIT License