nativephp

package
v1.35.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package nativephp runs PHP-FPM on the host instead of in a container, for sites whose runtime is "native". macOS bind-mounts the project into the podman VM, so a containerised PHP pays a virtiofs crossing on every file it reads; running on the host removes that boundary entirely.

Index

Constants

View Source
const MinVersion = "8.1"

MinVersion is the oldest PHP with a native runtime. Below it the toolchain cannot produce a usable binary: static PHP carries no OPcache before 8.0, and 7.4 and 8.0 both fail to compile against the libxml2 and ICU the build uses, which would cost dom, simplexml, soap, xsl and intl even if they linked.

Variables

This section is empty.

Functions

func BinaryPath

func BinaryPath(version string) string

BinaryPath is where lerd keeps the native PHP-FPM for a version. Suffixed with the minor because a project's composer.lock was resolved against one, and deliberately not "php": that name in BinDir is the shim into the container, and a static binary written over it would send every php on the machine to a PHP with no lerd behind it.

func ConfPath

func ConfPath(version string) string

ConfPath is the generated php-fpm.conf for a version's native listener.

func DevtoolsExtensionPath

func DevtoolsExtensionPath(version string) string

DevtoolsExtensionPath is where a native build's query-capture extension lives when the build ships one. It is the engine-level collector behind the Debug window's query lens, compiled into the PHP image and shipped beside the binary here, the same way xdebug is.

Named per version because a PHP module is built against one PHP's ABI: an 8.4 module will not load into 8.5, and offering it would warn on every request while the lens stayed empty.

func Ensure

func Ensure(version string) error

Ensure brings a version's native FPM up: config and overrides on disk, the launchd job installed, and the process running. Safe to call repeatedly; an unchanged plist is left alone so a running FPM is not restarted for nothing.

func EnsureInstalled

func EnsureInstalled(version, binary string) error

EnsureInstalled reports whether the native runtime for a version is usable, naming what is missing rather than letting nginx fastcgi into a dead port.

func EnsureShim

func EnsureShim(version, cliBinary string) (string, error)

EnsureShim points ShimDir's php at the native CLI, replacing a stale link so a version switch or reinstall is picked up.

func EnsureSupported

func EnsureSupported(version string) error

EnsureSupported rejects a version no native build will ever exist for. A permanent limit is not a missing download, and the two need different words or the reader waits for a build that is never coming.

func Extensions

func Extensions(version string) ([]string, error)

Extensions reports what a version's native build carries, read from the binary itself so it cannot drift from what is actually installed. The list is the module names PHP prints, which callers should canonicalise before comparing (PHP prints OPcache as "Zend OPcache").

func FPMBinaryPath

func FPMBinaryPath(version string) string

FPMBinaryPath is where lerd keeps the native PHP-FPM for a version. Separate from BinaryPath because FPM and CLI are different SAPIs and different builds: FPM serves requests, the CLI runs artisan, composer and tinker.

func FPMConfig

func FPMConfig(version, errorLog string) (string, error)

FPMConfig renders the php-fpm.conf for a PHP version's native listener. Pool sizing mirrors the containerised pool so switching a site's runtime doesn't silently change how much concurrency it can absorb. PHP settings are deliberately absent: they come from IniScanDir, the same files the containers mount, so php:ini stays the single place they are edited.

func IniScanDir

func IniScanDir(version string) string

IniScanDir joins IniScanDirs into the PHP_INI_SCAN_DIR value PHP expects.

func IniScanDirs

func IniScanDirs(version string) []string

IniScanDirs returns the directories a native FPM scans for php.ini fragments, in load order. These are the same files the containers bind-mount into conf.d, so php:ini, dumps, the debug window and xdebug behave identically whichever runtime a site is on. Order matches the containers' numeric conf.d prefixes (94-mail, 95-shared, 96-devtools, 97-dump, then the per-version 98-user and 99-xdebug).

func ListInstalled

func ListInstalled() []string

ListInstalled returns the PHP versions with a usable native runtime on disk, sorted. A version needs both SAPIs: the CLI runs artisan, composer and the workers, and FPM serves requests, so a half-installed version would list as available and then fail at whichever half is missing.

func LogPath

func LogPath(version string) string

LogPath is where a version's native FPM writes.

func ModulesDir

func ModulesDir(version string) string

ModulesDir holds the shared objects a native build ships beside its binary. Per version, because they are named for the extension and not for the PHP they were built against: one directory would leave every version loading whichever xdebug.so was installed last, and a module only loads into the ABI it was compiled for.

func OverrideDir

func OverrideDir(version string) string

OverrideDir holds the ini fragment that rewrites container paths to host ones. Scanned last so it wins over the copies the containers share.

func PortFor

func PortFor(version string) (int, error)

PortFor returns the loopback port the native FPM for a PHP version listens on. Derived from the version rather than allocated, so it survives restarts with nothing persisted and stays the same across machines.

func Reload

func Reload(version string) error

Reload restarts a version's native FPM so a changed php.ini reaches the processes handling requests. Ensure is deliberately a no-op for a listener that is already up, which is right on start and wrong after an ini edit.

func ShimDir

func ShimDir(version string) string

ShimDir holds a "php" symlink to the native CLI for a version. Workers run their command through a shell, so this goes on PATH ahead of BinDir, whose own "php" is the shim into the container. Without it a native site's workers would keep running containerised while its web requests did not.

func Stop

func Stop(version string) error

Stop takes a version's native FPM down and removes its launchd job.

func Supported

func Supported(version string) bool

Supported reports whether a PHP version has a native runtime.

func ToolName

func ToolName(version string) string

ToolName is the manifest entry and version-stamp name for a version's host build. Shared so the CLI that installs it and the dashboard that reports on it cannot disagree about what the stamp beside the binary is called.

func UnitLabel

func UnitLabel(version string) string

UnitLabel is the launchd label supervising a version's native FPM.

func WriteOverrides

func WriteOverrides(version string) error

WriteOverrides materialises the override fragment for a version.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL