.phar stands for PHP Archive
Usually .phar takes some arguments, so they are intended to be run from the command line. Linux / BSD / OS X shell or Windows command line.
Linux use .phar assumes that .phar copied to some kind of / bin and renamed without the .phar extension, so you can use the php archive as if you were using any other linux command. Therefore, I recommend the following way to do the same with Windows:
- Put all your
.phar files in one directory, e.g. C:\php\phars - Add
C:\php\phars to the system environment variables (right click on my Computer -> Properties -> Advanced System Settings -> Environment variables ) - Run the elevated command prompt (find the command prompt in the Start menu, then right-click and select
Run as Administrator ) - Enter the following commands, replacing the path
C:\phpdev\php\php542\php.exe with the full path to the PHP executable:
ftype PHARFile=C:\phpdev\php\php542\php.exe "%1" %* assoc .phar=PHARFile set PATHEXT=%PATHEXT%;.PHAR
The next time you can start the Windows console ( Win + R keyboard and type cmd.exe ) and type any of your .phar , for example apigen.phar , and then any command, and it will work
C:\Users\acosonic>apigen.phar help Usage: ... Arguments: command The command to execute command_name The command name (default: "help") Options: --xml To output help as XML --format To output help in other formats (default: "txt") --raw To output raw command help --help (-h) Display this help message. --quiet (-q) Do not output any message. --version (-V) Display this application version. Help: The help command displays help for a given command: php C:\phpdev\phars\apigen.phar help list You can also output the help in other formats by using the --format option: php C:\phpdev\phars\apigen.phar help --format=xml list To display the list of available commands, please use the list command. C:\Users\acosonic>
Thus, this method allows you to run .phar archives in the directory where you need to work, for example, when creating documentation in C:\myproject\controller without specifying the full path to .phar , as if it were executed without adding it to the Windows path.
To explain what the teams did in step 4:
- Display created HKCR.phar → HKCR \ PHARFile
- Created by HKCR \ PHARFile \ shell \ open \ command = 'php.exe "% 1"% *' [REG_EXPAND_SZ]
- Extended HKCU \ Environment \ PATHEXT = '% PATHEXT%;. PHAR '[REG_EXPAND_SZ]
*.phar processed as a binary file / script, and *.phar works while the *.phar file is somewhere in %PATH% .
Aleksandar Pavić
source share