Bootstrapper
class Bootstrapper
Constants
| protected RUNTIME_PROCESS_MARKER |
|
Properties
| static protected Config|null | $configuration | ||
| static protected Filesystem|null | $filesystem | ||
| static protected string|null | $runtimePath | The path to the disposable runtime copy of the workbench. |
|
| static protected string|null | $runtimeSourcePath | The skeleton directory the runtime copy was made from. |
|
| static protected string|null | $runtimeVendorPath | The working package's vendor directory, which the runtime copy links when its skeleton has none. |
Methods
Bootstrap the testbench environment.
Get the configuration attributes as an array.
Get the cached configuration instance.
Determine if the given path is the disposable runtime copy created by this process.
Get the skeleton directory the runtime copy created by this process was made from.
Get the working package's vendor directory, which the runtime copy created by this process links when its skeleton has none.
Determine if the given path is a disposable runtime copy.
Get the application base path set explicitly through APP_BASE_PATH.
Get the persistent application base path a Testbench command runs on.
Get the filesystem instance.
Load and cache the configuration from the Yaml file.
Resolve the directory that owns the active testbench.yaml file.
Determine if the given path contains a testbench configuration file.
Make a relative COMPOSER_VENDOR_DIR absolute against the package root.
Create a disposable runtime copy of the skeleton directory.
Copy the skeleton into the runtime copy.
Purge stale runtime copies left by interrupted test processes.
Copy the package or workbench environment file into the runtime copy.
Determine the active Testbench environment file name.
Resolve the runtime base path for the current process.
Get the parent's base path that a remote child process shares.
Delete the disposable runtime copy.
Delete a runtime copy on a best-effort basis.
Determine if the given PID is an orphaned serve process.
Determine whether a process identity matches a Testbench serve runtime.
Read the OS identity of the process incarnation.
Kill a process and all its descendants.
Collect all descendant PIDs of the given PID in depth-first order.
Build a map of PID → direct child PIDs by scanning /proc once.
Flush all static state.
Details
at line 50
static void
bootstrap(string|null $configurationPath = null)
Bootstrap the testbench environment.
at line 93
static array
getConfig()
Get the configuration attributes as an array.
at line 103
static Config|null
getConfiguration()
Get the cached configuration instance.
at line 113
static bool
ownsRuntimePath(string $path)
Determine if the given path is the disposable runtime copy created by this process.
Remote child processes and predefined base paths use a runtime they do not own.
at line 130
static string|null
runtimeSourcePath()
Get the skeleton directory the runtime copy created by this process was made from.
Static analysis tracks a copied file through its skeleton source, because the copy is deleted when the process exits.
at line 139
static string|null
runtimeVendorPath()
Get the working package's vendor directory, which the runtime copy created by this process links when its skeleton has none.
at line 150
static bool
isRuntimeCopy(string $path)
Determine if the given path is a disposable runtime copy.
A remote child may borrow its parent's copy; the parent reports that when it starts the child. Borrowing a copy does not make the child its owner.
at line 174
static string|null
explicitApplicationBasePath()
Get the application base path set explicitly through APP_BASE_PATH.
The lookup order matches the framework's base path inference, so the value is found whether or not PHP copies the process environment into $_ENV.
at line 188
static string|null
commandApplicationBasePath(Config $config, string $workingPath)
Get the persistent application base path a Testbench command runs on.
An explicit APP_BASE_PATH takes precedence over the configured skeleton. Tests never use the configured skeleton directly; they run on a disposable copy.
at line 197
static protected Filesystem
getFilesystem()
Get the filesystem instance.
at line 211
static protected void
loadConfigFromYaml(string $workingPath, string|null $filename = 'testbench.yaml', array $defaults = [])
Load and cache the configuration from the Yaml file.
at line 219
static string
resolveConfigurationPath(string $workingPath)
Resolve the directory that owns the active testbench.yaml file.
at line 233
static protected bool
hasConfigurationFile(string $workingPath, string $filename = 'testbench.yaml')
Determine if the given path contains a testbench configuration file.
at line 251
static protected void
exportAbsoluteComposerVendorDirectory(string $workingPath)
Make a relative COMPOSER_VENDOR_DIR absolute against the package root.
Applications run from a runtime copy or skeleton, including child processes that inherit this environment such as the skeleton's artisan, resolve a relative value against their own base path rather than the package root.
at line 275
static protected string
createRuntimeCopy(string $sourcePath, string $workingPath)
Create a disposable runtime copy of the skeleton directory.
Tests write generated files (make:provider, make:model, etc.) and mutate bootstrap/providers.php into the app's basePath. By copying the skeleton to a temp directory and using that as BASE_PATH, the committed skeleton stays clean. The copy is deleted on shutdown.
at line 359
static protected bool
copySkeleton(Filesystem $filesystem, string $sourcePath, string $runtimePath, string $workingVendorPath)
Copy the skeleton into the runtime copy.
Preserve a configured skeleton's vendor link, or link the package's dependencies when the skeleton has none. Each worker can then discover installed packages without changing the shared skeleton or copying its dependencies.
at line 405
static protected void
purgeStaleRuntimeCopies(string $tempDirectory, int $pid)
Purge stale runtime copies left by interrupted test processes.
at line 457
static protected void
copyPackageEnvironmentFile(Filesystem $filesystem, string $runtimePath, string $workingPath)
Copy the package or workbench environment file into the runtime copy.
at line 474
static protected string
testbenchEnvironmentFile()
Determine the active Testbench environment file name.
at line 487
static protected string
resolveRuntimeBasePath(string $sourcePath, string $workingPath)
Resolve the runtime base path for the current process.
at line 495
static protected string|null
parentBasePath()
Get the parent's base path that a remote child process shares.
at line 508
static protected void
deleteRuntimeCopy()
Delete the disposable runtime copy.
at line 526
static protected void
deleteRuntimeDirectory(string $directory)
Delete a runtime copy on a best-effort basis.
Callers that require the path to be absent must verify that postcondition.
at line 543
static protected bool
isOrphanedServeProcess(int $pid, string $runtimeDir)
Determine if the given PID is an orphaned serve process.
A process is considered an orphaned serve process only when its parent is init and its PID file and process incarnation match the runtime.
at line 578
static protected bool
matchesServeProcessIdentity(int $pid, string $runtimeDir)
Determine whether a process identity matches a Testbench serve runtime.
at line 624
static protected string|null
processStartIdentity(int $pid)
Read the OS identity of the process incarnation.
Linux exposes the start clock tick exactly. macOS lstart has one-second
resolution, the most precise portable process-start identity available there.
at line 659
static protected void
killProcessTree(int $pid)
Kill a process and all its descendants.
Collects the full descendant tree first (single /proc scan), then kills leaves before parents to avoid re-parenting races where killing a parent causes its children to be adopted by init before we can find them.
at line 684
static protected array
collectDescendants(int $rootPid)
Collect all descendant PIDs of the given PID in depth-first order.
Scans /proc once to build a PID→children map, then walks the subtree. Returns PIDs in parent-before-children order.
at line 708
static protected array
buildChildrenMap()
Build a map of PID → direct child PIDs by scanning /proc once.
at line 753
static void
flushState()
Flush all static state.