首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >多个php版本的composer使用

多个php版本的composer使用

原创
作者头像
高老师
发布于 2023-06-29 23:05:14
发布于 2023-06-29 23:05:14
1.6K0
举报

因为项目中使用swoole开发,一直使用win10 ubuntu子系统开发,随着代码量的增加,每次启动越来越慢。swoole官方提供了一个windows版swoole,启动速度特别快。但是由于其使用cgwin编译,所以无法正常使用composer,每次都需要切换php的环境变量。于是就想能不能让composer 识别我原来的php版本。打开composer的根文件试试真的可以。

composer文件: D:\Program Files\composer\composer

(1).原代码:

代码语言:javascript
复制
#!/bin/sh

dir=$(cd "${0%[/\\]*}" > /dev/null; pwd)

if [[ -d /proc/cygdrive && $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
   # We are in Cgywin using Windows php, so the path must be translated
   dir=$(cygpath -m "$dir");
fi

php "${dir}/composer.phar" "$@"

(2).修改后代码

代码语言:javascript
复制
#!/bin/sh

dir=$(cd "${0%[/\\]*}" > /dev/null; pwd)

if [[ -d /proc/cygdrive && $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
   # We are in Cgywin using Windows php, so the path must be translated
   dir=$(cygpath -m "$dir");
fi

D:/phpStudy/PHPTutorial/php/php-7.0.12-nts/php "${dir}/composer.phar" "$@"

只是将php的地址修改下即可,让composer每次加载我的phpstudy的php版本

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档