我们使用 PHP Composer,最常用的功能当然是获取并安装第三方库包在我们项目里了。我们这里用一个例子来学习怎么使用 PHP Composer 获取并安装第三方库包phpword。
环境准备
1、假设我们的项目是在:D:\study文件夹下,并且通过了虚拟主机配置,可以在浏览器通过http://localhost/或者其他配置的虚拟域名可以访问该文件夹下的php文件。
2、按照上一篇文章《安装PHP Composer》的介绍,已经安装了PHP Composer。
composer require
win+r 快捷键打开cmd命令对话框,在命令行模式下切换到D:\study文件夹下:
D:
cd study
使用 composer require 命令来获取 phpword:
composer require phpoffice/phpword
执行该命令的显示结果:
D:\study>composer require phpoffice/phpword
Using version ^0.17.0 for phpoffice/phpword
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
- Installing pclzip/pclzip (2.8.2): Downloading (100%)
- Installi