composer多版本切换

composer 安装目录:

1
C:\ProgramData\ComposerSetup\bin

新建composer8.bat文件

1
2
3
4
@echo OFF
:: in case DelayedExpansion is on and a path contains !
setlocal DISABLEDELAYEDEXPANSION
php8 "%~dp0composer.phar" %*

其中php8文件可参考php多版本切换功能

php8.bat文件内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@ECHO off
rem 设置目标路径
SET DIR=D:\phpstudy_pro\Extensions\php\php8.2.9nts
IF DEFINED ORIGIN_PATH (
SET PATH="%ORIGIN_PATH%"
)
rem 去除变量中所有的引号
SET PATH=%PATH:"=%
SET ORIGIN_PATH=%PATH%
SET PATH=%DIR%;%PATH%
SET PARAM=%~1
IF NOT DEFINED PARAM (
php -v
GOTO end
)

php %~1 %~2 %~3 %~4 %~5 %~6 %~7 %~8 %~9

:end
rem SET PATH=%ORIGIN_PATH%