|
1 | 1 | @echo off
|
2 |
| -:: Prefer PHP binary in the following order: |
3 |
| -:: 1. Whatever %PHPBIN% points to. |
4 |
| -:: 2. "php" from %cd% with one of %pathext% extensions. |
5 |
| -:: 3. "php" from a %path% path with one of %pathext% extensions. |
6 |
| -:: 4. Whatever %PHP_PEAR_PHP_BIN% points to. |
7 |
| -:: |
8 |
| -:: Once a binary is found, a file with the same name as this one |
9 |
| -:: will be ran. Prefered extensions are no extension and ".php" |
10 |
| -:: in this order. |
11 |
| -:: |
| 2 | +REM Prefer PHP binary in the following order: |
| 3 | +REM 1. Whatever %PHPBIN% points to. |
| 4 | +REM 2. "php" from %cd% with one of %pathext% extensions. |
| 5 | +REM 3. "php" from a %path% path with one of %pathext% extensions. |
| 6 | +REM 4. Whatever %PHP_PEAR_PHP_BIN% points to. |
| 7 | +REM |
| 8 | +REM Once a binary is found, a file is looked for at the %PHPFILE% environment |
| 9 | +REM variable (not intendend to be overriden). |
| 10 | +REM Fallbacks to a file with the same name as this one. |
| 11 | +REM Prefered extensions are ".php" and then no extension. |
| 12 | +REM |
| 13 | +goto SET_BIN |
| 14 | +:PHP_ERR |
| 15 | +echo PHP interpreter not found. Please set the %%PHPBIN%% or %%PHP_PEAR_PHP_BIN%% environment variable to one, or add one to your %%PATH%%. |
| 16 | +goto DONE |
| 17 | +:FILE_ERR |
| 18 | +echo The file to be ran was not found. It should be at either "%~d0%~p0%~n0.php" or "%~d0%~p0%~n0". |
| 19 | +goto DONE |
| 20 | +:SET_BIN |
12 | 21 | if "%PHPBIN%" == "" set PHPBIN=php
|
13 |
| -if exist "%PHPBIN%" goto SET_FILE |
14 |
| -if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_BIN |
15 |
| -goto PHP_ERR |
16 |
| -:USE_PEAR_BIN |
| 22 | +where /q %PHPBIN% |
| 23 | +if %ERRORLEVEL% == 0 goto SET_FILE |
| 24 | +if "%PHP_PEAR_PHP_BIN%" == "" goto PHP_ERR |
| 25 | +where /q "%PHP_PEAR_PHP_BIN%" |
| 26 | +if %ERRORLEVEL% neq 0 goto PHP_ERR |
17 | 27 | set PHPBIN=%PHP_PEAR_PHP_BIN%
|
18 |
| -if exist "%PHP_PEAR_PHP_BIN%" goto SET_FILE |
19 |
| -goto PHP_ERR |
20 | 28 | :SET_FILE
|
21 |
| -if "%PHPFILE%" == "" set PHPFILE=%~d0%~p0%~n0 |
22 |
| -if exist "%PHPFILE%" goto RUN |
23 |
| -set PHPFILE=%~d0%~p0%~n0.php |
| 29 | +if "%PHPFILE%" == "" set PHPFILE=%~d0%~p0%~n0.php |
24 | 30 | if exist "%PHPFILE%" goto RUN
|
25 |
| -goto FILE_ERR |
| 31 | +set PHPFILE=%~d0%~p0%~n0 |
| 32 | +if not exist "%PHPFILE%" goto FILE_ERR |
26 | 33 | :RUN
|
27 | 34 | "%PHPBIN%" "%PHPFILE%" %*
|
28 |
| -goto DONE |
29 |
| -:PHP_ERR |
30 |
| -echo PHP interpreter not found. Please set the %%PHPBIN%% or %%PHP_PEAR_PHP_BIN%% environment variable to one, or add a PHP interpreter to your %%PATH%%. |
31 |
| -goto DONE |
32 |
| -:FILE_ERR |
33 |
| -echo The file to be ran was not found. It should be in the same folder, and either have a ".php" extension, or no extension at all. |
34 | 35 | :DONE
|
0 commit comments