Documentation
¶
Index ¶
- Variables
- func ClampToRange(version, min, max string) string
- func CompareMajorMinor(a, b string) int
- func DetectExtensions(dir string) []string
- func DetectVersion(dir string) (string, error)
- func DetectVersionClamped(dir, phpMin, phpMax, fallback string) string
- func FPMInstalled(version, container string) bool
- func IsInstalled(version string) bool
- func IsPHPProject(dir string) bool
- func ListInstalled() ([]string, error)
- func SiteUsesPHP(s config.Site) bool
- func StartFPM(version, container string) error
Constants ¶
This section is empty.
Variables ¶
var ErrFPMNotInstalled = errors.New("FPM container is not installed")
ErrFPMNotInstalled is returned (wrapped) by StartFPM when the requested version's FPM container does not exist yet, so the caller knows the fix is to install it rather than just start it. Test with errors.Is.
Functions ¶
func ClampToRange ¶ added in v1.10.0
ClampToRange checks if version falls within [min, max] and returns the best installed version within range if it doesn't. Returns the original version if min/max are empty or the version is already in range. This is used to respect framework PHP version constraints during site linking.
func CompareMajorMinor ¶ added in v1.26.0
CompareMajorMinor compares two "major.minor" version strings numerically and returns -1, 0, or 1. An unparseable version sorts below any numeric one.
func DetectExtensions ¶ added in v0.5.5
DetectExtensions reads composer.json in dir and returns the list of PHP extensions declared in the require map (ext-* keys), with the "ext-" prefix stripped. Returns an empty slice on any error (non-fatal).
func DetectVersion ¶
DetectVersion detects the PHP version for the given directory. It checks, in order:
- .lerd.yaml php_version field (explicit lerd override)
- .php-version file (explicit per-project pin)
- composer.json require.php semver (project requirement)
- global config default
func DetectVersionClamped ¶ added in v1.11.0
DetectVersionClamped detects the PHP version and clamps it to the given range. If phpMin/phpMax are empty, no clamping is applied.
func FPMInstalled ¶ added in v1.27.0
FPMInstalled reports whether the FPM container already exists (so it only needs starting) rather than needing a fresh build. It checks both the shared per-version units and the specific container's unit, so a custom-FPM container (lerd-cfpm-<site>, whose version isn't in the shared list) is recognised too.
func IsInstalled ¶
IsInstalled returns true if the given PHP version has an FPM quadlet.
func IsPHPProject ¶ added in v1.23.0
IsPHPProject reports whether dir looks like a PHP project: it has a composer.json or any top-level .php file. Static sites (a public dir with no PHP) and non-PHP projects return false, so callers can hide PHP-only surfaces like the version dropdown, Tinker, Xdebug, dumps and FPM logs.
func ListInstalled ¶
ListInstalled returns all PHP versions that have an FPM quadlet file or a running/existing Podman container, e.g. ["8.3", "8.4"]. The two sources are merged so users whose quadlet file is missing but whose container still exists are not excluded.
func SiteUsesPHP ¶ added in v1.23.0
SiteUsesPHP reports whether the site is a PHP project served by lerd's PHP runtime (the shared FPM image or FrankenPHP), as opposed to a static site or a custom container. It mirrors the registration decision in cli.RegisterProject: a framework, a composer.json / top-level .php file, or a public dir with an index.php entrypoint all count as PHP. Custom containers and static sites (a public dir of HTML only) return false.
func StartFPM ¶ added in v1.27.0
StartFPM brings up a stopped-but-installed FPM container and waits for it to report running, so an exec right after doesn't race the boot. It is a no-op when the container is already running and returns ErrFPMNotInstalled (wrapped with the version) when the container doesn't exist yet. It produces no output; callers add any user-facing progress. Shared by the CLI php/artisan/shell commands and the MCP exec handlers so both auto-start the same way.
Types ¶
This section is empty.