xp-framework / core

The XP Framework is an all-purpose, object oriented PHP framework.
Other
19 stars 6 forks source link

Add CommandLine::resolve() #281

Closed thekid closed 3 years ago

thekid commented 3 years ago

This pull request adds a new method resolve() to the lang.CommandLine class which finds executables in the system path. This method supersedes lang.Process::resolve() which is therefore deprecated.

# Windows
$ xp -w '[...lang\CommandLine::forName(PHP_OS)->resolve("curl")]'
["C:\Tools\Cygwin\bin\curl.exe", "C:\Windows\System32\curl.exe"]

# Un*x
$ xp -w '[...lang\CommandLine::forName(PHP_OS)->resolve("which")]'
["/usr/bin/which", "/bin/which"]

Windows

Note: If you want to execute .bat files, you need to use cmd /c [file].bat in order for this to work!

Un*x

Note: The executable bit must be set effectively for the current user for a file to be regarded executable

thekid commented 3 years ago

Released in https://github.com/xp-framework/core/releases/tag/v10.14.0