Home > Article > Development Tools > Teach you how to manually install composer under windows
The following tutorial column will introduce to you how to manually install composer under windows. I hope it will be useful to friends who need it. Helped!
composer is a PHP dependency management tool. Installation under Windows is often blocked. Now we provide a manual The installation method is for reference only1. Preparation before installation
(1)Composer requires PHP 5.3.2 to run
(2) Add the path variable to the php running directory.
That is to ensure that you can directly run php -v when opening cmd anywhere (3) Make sure that php opens the openssl extension
Search for OpenSSL in php.ini and remove the previous Semicolon, save and restart the server.
2. Install and configure composer
(1) Download composer.phar
https://getcomposer.org/composer.phar 下载到本地 (例如F:\tools\composer)cmd and run
cd F:\tools\composer
F:
php composer.phar -v
(2) Add the directory where composer.phar is located to the path environment variable (3) Create a composer shortcut command
##
cd F:\tools\composer F: echo @php "%~dp0composer.phar" %*>composer.bat
is in F:\tools\composer has created a composer.bat batch file, and F:\tools\composer has been added to the environment variable. In the future, entering composer anywhere will be equivalent to
php
composer.phar
(4) Modify the image Japanese image address
http://composer-proxy.jp/proxy/packagistcan be set globally You can also set it as needed
In order to avoid performing two queries when installing the package, remember to add disable Packagist settings
Global settings 查看 composer 主目录:通过 进入 composer 的主目录,打开 按需设置 如果只需要特定的项目指定特定的镜像,则不需修改全局设置,在需要的地方进行修改 以 laravel 项目的 composer
config -l -g
命令可以列出 composer 的全局配置信息,在这些信息中查找[home]
配置项就是
composer 的主目录。config.json
文件(如果没有就自己创建一个),然后增加本镜像服务的配置信息,最终内容如下:{
"config": {
},
"repositories": [
{"type": "composer", "url": "http://composer-proxy.jp/proxy/packagist"},
{"packagist": false}
]
}
composer.json
配置文件为例,添加本镜像服务配置信息后如下所示(注意最后几行):{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [ "database"
],
"psr-4": {
"App\\": "app/"
} },
"autoload-dev": {
"classmap": [ "tests/TestCase.php"
] },
"config": {
"preferred-install": "dist"
} "repositories": [
{"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},
{"packagist": false}
]}
The above is the detailed content of Teach you how to manually install composer under windows. For more information, please follow other related articles on the PHP Chinese website!