php下composer初体验

  |   0 评论   |   0 浏览

背景

跑一个代码库没跑起来,原因是其使用了composer。其中的代码片断为:

require_once PROJECT_ROOT . 'vendor/autoload.php';

如果没有安装的话,会跑不起来。

初体验

环境准备

首先肯定有一个 composer.json 文件了。

安装

sudo apt-get install composer

安装包

composer install

更新包

composer update

结果

Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating autoload files
24 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

FAQ

降级版本

Ocramius/ProxyManager在某些情况下,会报错 # getAllRawData not found in InstalledVersions,需要降级到 2.11.1。

查看当前版本:

composer show ocramius/proxy-manager

结果

versions : * 2.12.1

降级,修改 composer.json文件

"ocramius/proxy-manager": "2.11.1"

再执行

composer update

参考

  1. PHP开发环境:如何安装Composer
  2. 基本用法