Which for PHP

Finder
in package

FinalYes

Finds the instances of an executable in the system path.

Table of Contents

Properties

$extensions  : array<string|int, string>
The list of executable file extensions.
$paths  : array<string|int, string>
The list of system paths.

Methods

__construct()  : mixed
Creates a new finder.
find()  : Generator<int, SplFileInfo>
Finds the instances of an executable in the system path.
isExecutable()  : bool
Gets a value indicating whether the specified file is executable.
isWindows()  : bool
Gets a value indicating whether the current platform is Windows.

Properties

$extensions read-only

The list of executable file extensions.

public array<string|int, string> $extensions

$paths read-only

The list of system paths.

public array<string|int, string> $paths

Methods

__construct()

Creates a new finder.

public __construct([array<string|int, string> $paths = [] ][, array<string|int, string> $extensions = [] ]) : mixed
Parameters
$paths : array<string|int, string> = []

The system path. Defaults to the PATH environment variable.

$extensions : array<string|int, string> = []

The executable file extensions. Defaults to the PATHEXT environment variable.

find()

Finds the instances of an executable in the system path.

public find(string $command) : Generator<int, SplFileInfo>
Parameters
$command : string

The command to be resolved.

Return values
Generator<int, SplFileInfo>

The paths of the executables found.

isExecutable()

Gets a value indicating whether the specified file is executable.

public isExecutable(string $file) : bool
Parameters
$file : string

The path of the file to be checked.

Return values
bool

true if the specified file is executable, otherwise false.

isWindows()

Gets a value indicating whether the current platform is Windows.

public static isWindows() : bool
Return values
bool

true if the current platform is Windows, otherwise false.


        
On this page

Search results