如何在Windows使用Composer
1个回答
展开全部
设置php.ini,方便安装
在从官网下载 Composer-Setup.exe安装程序后,在安装过程中会碰到几个麻烦的地方:
1. 找不到扩展dll文件,修改php.ini文件内 extension_dir 参数
2. browscap未找到,修改php.ini文件内 browscap参数
3. SSL dll未找到,修改php.ini文件内";extension=php_openssl.dll",去掉前面“;”
正确的安装画面,如下:
使用Composer中文镜像网站,替代国外网站
当你安装完Composer后,使用时,缺发现不能下载包,这是一个众所周知的原因。
所以,我们要什么国内的镜像站点进行代替,常用方法有两种:
1. 修改全局配置:全局配置的文件一般放在 C:\Users\XXX\AppData\Roaming\Composer\config.json;
{ "config": { }, "repositories": [ {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"}, {"packagist": false ] }
2. 修改当前配置:即项目当前的composer.json文件;
以 laravel 项目的 composer.json 配置文件为例:
{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "laravel/framework": "4.2.*" }, "autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php" ] }, "scripts": { "post-install-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-update-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-create-project-cmd": [ "php artisan key:generate" ] }, "config": { "preferred-install": "dist" }, "minimum-stability": "stable", "repositories": [ {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"}, {"packagist": false} ] }
在从官网下载 Composer-Setup.exe安装程序后,在安装过程中会碰到几个麻烦的地方:
1. 找不到扩展dll文件,修改php.ini文件内 extension_dir 参数
2. browscap未找到,修改php.ini文件内 browscap参数
3. SSL dll未找到,修改php.ini文件内";extension=php_openssl.dll",去掉前面“;”
正确的安装画面,如下:
使用Composer中文镜像网站,替代国外网站
当你安装完Composer后,使用时,缺发现不能下载包,这是一个众所周知的原因。
所以,我们要什么国内的镜像站点进行代替,常用方法有两种:
1. 修改全局配置:全局配置的文件一般放在 C:\Users\XXX\AppData\Roaming\Composer\config.json;
{ "config": { }, "repositories": [ {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"}, {"packagist": false ] }
2. 修改当前配置:即项目当前的composer.json文件;
以 laravel 项目的 composer.json 配置文件为例:
{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "laravel/framework": "4.2.*" }, "autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php" ] }, "scripts": { "post-install-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-update-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-create-project-cmd": [ "php artisan key:generate" ] }, "config": { "preferred-install": "dist" }, "minimum-stability": "stable", "repositories": [ {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"}, {"packagist": false} ] }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询