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.

Methods

static void
bootstrap()

Bootstrap the testbench environment.

static array
getConfig()

Get the configuration attributes as an array.

static Config|null
getConfiguration()

Get the cached configuration instance.

static Filesystem
getFilesystem()

Get the filesystem instance.

static void
loadConfigFromYaml(string $workingPath, string|null $filename = 'testbench.yaml', array $defaults = [])

No description

static string
resolveConfigurationPath(string $workingPath)

Resolve the directory that owns the active testbench.yaml file.

static bool
hasConfigurationFile(string $workingPath, string $filename = 'testbench.yaml')

Determine if the given path contains a testbench configuration file.

static string
createRuntimeCopy(string $sourcePath, string $workingPath)

Create a disposable runtime copy of the skeleton directory.

static void
copyPackageEnvironmentFile(Filesystem $filesystem, string $runtimePath, string $workingPath)

Copy the package or workbench environment file into the runtime copy.

static string
testbenchEnvironmentFile()

Determine the active Testbench environment file name.

static string
resolveRuntimeBasePath(string $sourcePath, string $workingPath)

Resolve the runtime base path for the current process.

static void
deleteRuntimeCopy()

Delete the disposable runtime copy.

static void
deleteRuntimeDirectory(string $directory)

Delete a runtime copy while tolerating sibling cleanup races.

static bool
runtimeDirectoryExists(Filesystem $filesystem, string $directory)

Determine if a runtime directory exists.

static bool
isOrphanedServeProcess(int $pid, string $runtimeDir)

Determine if the given PID is an orphaned serve process.

static bool
matchesServeProcessIdentity(int $pid, string $runtimeDir)

Determine whether a process identity matches a Testbench serve runtime.

static string|null
processCommand(int $pid)

Read the command line for a process.

static string|null
processStartIdentity(int $pid)

Read the OS identity of the process incarnation.

static void
killProcessTree(int $pid)

Kill a process and all its descendants.

static array
collectDescendants(int $rootPid)

Collect all descendant PIDs of the given PID in depth-first order.

static array
buildChildrenMap()

Build a map of PID → direct child PIDs by scanning /proc once.

static void
registerPurgeFiles()

Register shutdown handlers to purge configured files and directories.

static void
flushState()

Flush all static state.

Details

at line 35
static void bootstrap()

Bootstrap the testbench environment.

Return Value

void

at line 63
static array getConfig()

Get the configuration attributes as an array.

Return Value

array

at line 73
static Config|null getConfiguration()

Get the cached configuration instance.

Return Value

Config|null

at line 81
static protected Filesystem getFilesystem()

Get the filesystem instance.

Return Value

Filesystem

at line 90
static protected void loadConfigFromYaml(string $workingPath, string|null $filename = 'testbench.yaml', array $defaults = [])

No description

Parameters

string $workingPath
string|null $filename
array $defaults

Return Value

void

at line 98
static protected string resolveConfigurationPath(string $workingPath)

Resolve the directory that owns the active testbench.yaml file.

Parameters

string $workingPath

Return Value

string

at line 108
static protected bool hasConfigurationFile(string $workingPath, string $filename = 'testbench.yaml')

Determine if the given path contains a testbench configuration file.

Parameters

string $workingPath
string $filename

Return Value

bool

at line 127
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.

Parameters

string $sourcePath
string $workingPath

Return Value

string

at line 207
static protected void copyPackageEnvironmentFile(Filesystem $filesystem, string $runtimePath, string $workingPath)

Copy the package or workbench environment file into the runtime copy.

Parameters

Filesystem $filesystem
string $runtimePath
string $workingPath

Return Value

void

at line 223
static protected string testbenchEnvironmentFile()

Determine the active Testbench environment file name.

Return Value

string

at line 235
static protected string resolveRuntimeBasePath(string $sourcePath, string $workingPath)

Resolve the runtime base path for the current process.

Parameters

string $sourcePath
string $workingPath

Return Value

string

at line 250
static protected void deleteRuntimeCopy()

Delete the disposable runtime copy.

Return Value

void

at line 269
static protected void deleteRuntimeDirectory(string $directory)

Delete a runtime copy while tolerating sibling cleanup races.

Multiple same-token Testbench children can bootstrap at once and purge the same stale runtime copy. If another child wins the race, the missing directory is the desired postcondition; if the directory remains, the original filesystem failure is still surfaced.

Parameters

string $directory

Return Value

void

at line 305
static protected bool runtimeDirectoryExists(Filesystem $filesystem, string $directory)

Determine if a runtime directory exists.

Parameters

Filesystem $filesystem
string $directory

Return Value

bool

at line 317
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, command, and process incarnation all match the runtime directory.

Parameters

int $pid
string $runtimeDir

Return Value

bool

at line 352
static protected bool matchesServeProcessIdentity(int $pid, string $runtimeDir)

Determine whether a process identity matches a Testbench serve runtime.

Parameters

int $pid
string $runtimeDir

Return Value

bool

at line 405
static protected string|null processCommand(int $pid)

Read the command line for a process.

Parameters

int $pid

Return Value

string|null

at line 433
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, which is sufficient alongside the PID and validated command.

Parameters

int $pid

Return Value

string|null

at line 468
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.

Parameters

int $pid

Return Value

void

at line 493
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.

Parameters

int $rootPid

Return Value

array

at line 517
static protected array buildChildrenMap()

Build a map of PID → direct child PIDs by scanning /proc once.

Return Value

array

at line 562
static protected void registerPurgeFiles()

Register shutdown handlers to purge configured files and directories.

Return Value

void

at line 593
static void flushState()

Flush all static state.

Return Value

void