[TOC] #### 1. 前言 --- 版本號:[https://getcomposer.org/download](https://getcomposer.org/download "https://getcomposer.org/download") 中文網(wǎng):[https://docs.phpcomposer.com/03-cli.html#self-update](https://docs.phpcomposer.com/03-cli.html#self-update "https://docs.phpcomposer.com/03-cli.html#self-update") 英文網(wǎng):[https://getcomposer.org/doc/03-cli.md#self-update-selfupdate](https://getcomposer.org/doc/03-cli.md#self-update-selfupdate- "https://getcomposer.org/doc/03-cli.md#self-update-selfupdate") #### 2. 更新版本 --- **查看當前composr版本(大寫的V)** ``` composer -V ``` **當前composer更新為最新版** ``` composer self-update ``` ![](https://img.itqaq.com/art/content/bf3421dda9b8d66bcc7928d6d6d89172.png) **更新到指定版本** ```php composer self-update 1.10.1 ``` ![](https://img.itqaq.com/art/content/fc04d5a054ef69695c79a125549a9a3c.png) 更新到指定大版本 ``` # 更新到 1.x 版本的最新穩(wěn)定版 composer self-update --1 # 更新到 2.x 版本的最新穩(wěn)定版 composer self-update --2 ``` mac 用戶需要使用 `sudo` ``` sudo composer self-update --2 ``` #### 3. 版本回滾 --- **回滾到安裝的上一個版本** ``` composer self-update -r ``` ![](https://img.itqaq.com/art/content/5a0e02e972c7cd9aabca2df80a128525.png) #### 4. 版本更新并刪除舊版本的備份 --- ```php composer self-update --clean-backups ```