Skip to content
PHP Ecosystem
Explore

ProjectRootFinder

API reference › Scaffold › Config › ProjectRootFinder

final classPHPForge\Scaffold\Config\ProjectRootFinder
Sourcesrc/Config/ProjectRootFinder.php

Finds the project root by walking up from a directory to the nearest one that contains the Composer manifest.

MethodDescriptionDefined by
find() staticReturns the nearest directory, starting at $directory and walking up, that contains the Composer manifest named by VendorDirResolver::manifestName().ProjectRootFinder
public static function find(string $directory): string|null

Returns the nearest directory, starting at $directory and walking up, that contains the Composer manifest named by VendorDirResolver::manifestName().

An absolute manifest path is not searched for: its directory is the project root, as for the Composer plugin.

Parameters

ParameterTypeDescription
$directorystringAbsolute path of the directory where the search starts.

Returns

string|null: Absolute path of the project root, or null when the filesystem root is reached first or the absolute manifest does not exist.