有没有办法在 Windows 上全局安装 Composer? [英] Is there any way to install Composer globally on Windows?

查看:34
本文介绍了有没有办法在 Windows 上全局安装 Composer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读 Composer 的全局安装文档,但它仅适用于 *nix 系统:

I've read the global installation documentation for Composer, but it's for *nix systems only:

curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

我会很高兴在 Windows 上做同样的事情,那是我开发机器的操作系统.我可以跑

I would be such happy doing the same on Windows, that's the OS of my development machine. I would be able to run

composer update

来自 composer.json 所在的任意文件夹.解释器 php.exe 已经在 PATH 变量中.

From an arbitrary folder where composer.json exists. Interpreter php.exe is already in PATH variable.

有什么线索吗?

推荐答案

当然.只需将 composer.phar 放在 C:phpcomposer.phar 之类的地方,然后在 PATH 中的某个地方创建一个名为 composer.bat 的批处理文件,该文件执行以下操作:

Sure. Just put composer.phar somewhere like C:phpcomposer.phar, then make a batch file somewhere within the PATH called composer.bat which does the following:

@ECHO OFF
php "%~dp0composer.phar" %*

%*"重复传递给 shell 脚本的所有参数.

The "%*" repeats all of the arguments passed to the shell script.

然后你就可以到处乱跑composer update了!

Then you can run around doing composer update all ya want!

这篇关于有没有办法在 Windows 上全局安装 Composer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆