有没有办法在 Windows 上全局安装 Composer?

Is there any way to install Composer globally on Windows?(有没有办法在 Windows 上全局安装 Composer?)
本文介绍了有没有办法在 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)