Home  >  Article  >  How to install PHP Composer on Windows 11 or 10

How to install PHP Composer on Windows 11 or 10

WBOY
WBOYforward
2023-05-15 19:40:043615browse

Steps to install PHP Composer on Windows 11 or 10

The steps given here can be used to install PHP composer on Windows 11 and 10 to start developing and testing various PHP applications that require additional libraries to work program.

There are two ways to install Composer on Windows, one is a pure command line, and the other is using a graphical user interface. Here we will show you both.

1. Open Windows Terminal

Right-click the Start button and run Windows Terminal (Administrator). Windows 10 users can use PowerShell (admin).

如何在 Windows 11 或 10 上安装 PHP Composer

2. Set up Chocolatey

Chocolatey is a popular Windows package manager. It helps us to install various packages using only one command. So, first, set it up using the given command:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

3. Install PHP on Windows 10 or 11

Well, Composer requires PHP to work. Therefore, we cannot set up Composer further without installing PHP. One of the easiest ways to get it is with Choco. Let’s use this Windows package manager and install it quickly.

choco install php
如何在 Windows 11 或 10 上安装 PHP Composer

Now, close Command Prompt or Powershell and reopen it again.

To check the PHP version, use:

php -v
如何在 Windows 11 或 10 上安装 PHP Composer

Method 1 #Use Command Prompt or Terminal

3. Command line to install Composer on Windows 11 or 10

Now, we have installed the latest version of PHP on Windows 11 or 10. Now, use the Choco package manager again to install the latest version of Composer on your system.

choco install composer

Close Command Prompt or Powershell and reopen again.

To check which version of composer is installed, use:

composer -v

如何在 Windows 11 或 10 上安装 PHP Composer

2nd Method: Using GUI

4. Download Composer for Windows 11 or 10

Once PHP is installed on your system, we can install Composer using the GUI interface. To do this, visit the official website of Composer and download it for Windows.

Click – Composer-Setup.exe to download its installer.

如何在 Windows 11 或 10 上安装 PHP Composer

Then click the "Install for all users (recommended)" option.

如何在 Windows 11 或 10 上安装 PHP Composer

5. Select PHP version for Composer

Follow the wizard and when it asks to select command line PHP, the installer will automatically detect Choco Have the latest version of PHP installed on your system. Leave it as is, unless you have multiple versions and want to use any of them. Then click the "Next" button and complete the Composer installation process.

如何在 Windows 11 或 10 上安装 PHP Composer

After that you can check its version. Just open command terminal and run:

composer -v

6. Uninstall or remove composer

Well, if you don’t need to install PHP and Composer on your system using Choco package manager, Then please use the given command to uninstall them.

choco uninstall php
choco uninstall composer

Users who install Composer using the GUI executable installation file.

The above is the detailed content of How to install PHP Composer on Windows 11 or 10. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yundongfang.com. If there is any infringement, please contact admin@php.cn delete