Table of Contents
回复内容:
Home Backend Development PHP Tutorial windows下如何在phpStudy下安装composer

windows下如何在phpStudy下安装composer

Jun 06, 2016 pm 08:46 PM
php

如题 phpStudy可以让我切换环境方便 还有一些一键功能很好用,现在比如选定 nigix+php5.3
如何安装composer呢
可能是要解决环境变量的设置?

回复内容:

如题 phpStudy可以让我切换环境方便 还有一些一键功能很好用,现在比如选定 nigix+php5.3
如何安装composer呢
可能是要解决环境变量的设置?

好吧,题主我已经装成功了,这里分享一下我的经验吧。其实安装过程中最坑爹的应该是下载那个composer.phar文件了,应该是网路的问题,题主你可以GFW一下试试效果,不过我这里是没有的。因为网络问题所以我放弃了用exe安装那个超便捷的方法,所以我是手动操作的。

首先你要设置PHP的环境变量,不过没有设置也关系不大,保证命令行能运行PHP就好了。

然后检查openssl插件有没有安装。

PHP命令行的配置文件和平常的配置文件(对应Web网站的)不是一个文件控制的,所以可能你php.ini文件里头加了openssl插件但是很可能命令行还是提示你没有加载(这也是之前我犯的错误)。

这里先推荐你装上Git Bash,这样你就可以在CMD里面使用Linux命令了。然后运行php -i | grep openssl看看有没有返回,如果有的话就是的确开启了。如果没有装Git Bash的也不要紧, CMD有自带命令php -i | findstr openssl可以用啦, 感谢 @Deloz 大大的友情提醒.

如果没有的话请先php -i | grep php.ini看一下配置文件在哪里(同样可以换成php -i | findstr php.ini),我这里显示的是C:\Windows。但是比较郁闷的是在该文件夹下我没发现有php.ini文件,然后我搜索了一下发现只要把我们平常用的php.ini复制到这里来,然后修改一下文件内的extension_dir地址到具体地址去就好了。

这会儿我们再运行php -i | grep openssl或者php -i | findstr openssl检查一般发现可以了。

下面再运行代码下载安装文件:curl -sS https://getcomposer.org/installer | php -- --version=1.0.0-alpha8 --filename=composer

我之前有单独安装过Curl所以运行curl命令无压力,如果不用curl的话直接https://getcomposer.org/installer访问这个地址复制另存下来也是没有问题的,比如你存下来的文件名为composer_install.php,那么你接下来就要运行php composer_install.php --version=1.0.0-alpha8 --filename=composer

这里最好指定一下--version这个参数,因为我没指定下载也还是失败(坑爹的网络)。多等一会儿应该就下好了(我这里是这样的),这样composer就算下载下来了。

运行的话也简单,到composer.json当前路径下运行php composer_dir install就好了,其中composer_dir对应的额是你的composer文件的地址。

我用 Windows 的时候还没有 Composer,现在已经不用 Windows 了,虽然没用过 phpStudy,但是 Composer 是一个依赖于 PHP 的命令行工具,所以跟 nginx 和其它是没啥关系的。仅仅和 PHP 及系统有关系。

如何在 Windows 上安装 Composer,官网已经写的很清楚了,具体看:
https://getcomposer.org/doc/00-intro.md#installation-windows

官网+1,另外还有个比较土的方法,适用于cygwin下使用composer,直接下载的composer.phar又没有配置全局变量时:

可以将composer.phar复制至相应项目目录下运行,例如每个Symfony项目根目录下,与composer.json并列。然后使用相应的

{path}/php composer.phar xxx

相关引用

出现这样的原因,你没有开启php的openssl扩展,在phpstudy中开启,然后安装就可以了。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

See all articles