Last active
May 2, 2020 15:26
-
-
Save tored/2cadac512f92d29b7b24da1af01104a3 to your computer and use it in GitHub Desktop.
Configurable execution of PHP scripts in Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
if "%PHP%"=="" ( | |
echo %%PHP%% is NOT defined | |
exit /b | |
) | |
%PHP% %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assoc .php=phpfile | |
ftype phpfile="C:\Tools\php.cmd" -f "%1" -- %~2 | |
assoc .phar=pharfile | |
ftype pharfile="C:\Tools\php.cmd" -f "%1" -- %~2 | |
setx /m PATHEXT %PATHEXT%;.PHP;.PHAR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run
register.cmd
as administrator in a prompt to register php files to be executed withphp.cmd
. Change environment variable%PHP%
to whatever php version you need to run, e.g.SET PHP=php-7.4
. Now you can run php files as any other executable.If you need access to
php
in your command line just putphp.cmd
somewhere in your%PATH%
.