php扩展和模块管理:pecl,composer
pecl
安装
yum -y install php72w-devel
yum -y install php72w-pear
使用
#参考 pecl help #列出全部命令 pecl help command-name #查看某个命令的用法 #配置 pecl config-show #查看 pecl list #已安装的扩展 pecl list-all #所有可以安装的扩展 pecl list-upgrades #可更新的扩展 pecl list-channels #本地配置的渠道列表 pecl info pack-name #安装 步骤包含(configure,make,make install) pecl install pack-name #升级(修改) pecl upgrade pack-name #卸载 pecl uninstall pack-name #搜索 pecl search pack-name #下载源码包 pecl download pack-name
composer
参考:https://pkg.phpcomposer.com/#how-to-install-composer(官方文档)
下载安装
#下载 php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');" #安装 #linux sudo mv composer.phar /usr/local/bin/composer #windows 1,composer.phar复制到php.exe的目录下 1,在php.exe的目录下,创建 composer.bat 2,内容:@php "%~dp0composer.phar" %*
使用
参考:https://getcomposer.org/doc/03-cli.md(官方文档)
#初始化 composer init #命令列表 composer list #命令说明 composer help command-name #配置 composer help config composer config -l #当前目录的composer.json配置 composer config -l -g #全局配置 composer confgi --editor [-g] #编辑composer.json配置 composer config key composer config key val compsser config --unset key #安装 composer install #通过composer.lock或composer.json安装 composer require pack-name #下载一个包 #卸载 composer remove pack-name #卸载一个包 #查看本地包列表 composer show #需要在composer项目目录种运行 composer show pack-name #查看某个包的使用信息 #搜索:从资源url处搜索 composer search pack-name #更新 composer update #全部更新 composer update pack-name1 [pack-name2...] #更新指定包 composer update pack-name:version #更新到指定版本 #其他 composer self-update #更新composer的本版 composer dump-autoload #刷新自动加载器,无需借组install或update
常见问题
1,安装php 包的时候包composer版本问题
requires composer-plugin-api ^1.1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint. #尝试: composer update -vvv composer diagnose
2,composer升级以后,laravvel项目的 Illuminate\Foundation\PackageManifest->build()会报错
if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) { $packages = json_decode($this->files->get($path), true); }
#$packages 替换为 $installed = json_decode($this->files->get($path), true); $packages = $installed['packages'] ?? $installed;
//或者尝试
composer self-update --rollback