Home  >  Article  >  Development Tools  >  Solution to the invalid composer command under windows

Solution to the invalid composer command under windows

藏色散人
藏色散人forward
2020-11-30 14:08:544418browse

The following tutorial column of composer will introduce to you the solution to the problem that composer cannot be installed or the composer command is invalid under windows. I hope it will be helpful to friends in need!

Solution to the invalid composer command under windows

Installation method: http://docs.phpcomposer.com/00-intro.html#Installation-Windows (official Chinese help document)

Problem Description 1: After the installation is completed through the Composer-Setup.exe the command is invalid, as shown below:

Solution to the invalid composer command under windows

Solution:

  • Check whether the system environment is automatically configured. If not, please add the Path variable: C:\ProgramData\ComposerSetup\bin
  • Open cmd and enter composer -v. If the following is displayed, the installation is successful and can be accessed globally.

Solution to the invalid composer command under windows

  • Switch to any directory and test againcomposer -v, the installation is successful as shown below.

Solution to the invalid composer command under windows

--- Separator ---

Problem Description 2: PassInstallation commandManual installation failed, as shown below:

Solution to the invalid composer command under windows

Solution:

  • No error message Composer that supports PHP5.5.12, update PHP version 5.6 and above
  • and re-install through the command. Before installation, please cd to the installation directory (you can create and specify it yourself ), for example:

C:\Users\username>cd D: Switch to D drive

C:\Users\username>cd D:\Composer Switch to the Composer folder (the installation directory you created)

D:\Composer>php -r "readfile('https://getcomposer.org/installer' );" | php Execute the installation command. From this step onwards, it is the same as the tutorial in the official document. Please check it yourself to complete the subsequent operations.

    • The file path after the installation is completed. At this time, the composer -v command can only be executed in this directory, that is, it can only be locally accessed. .
      Solution to the invalid composer command under windows

    • To global access, you need to configure the system environment variables yourself and add the Path variable: D:\Composer (Please modify it according to your own installation directory)

The above is the detailed content of Solution to the invalid composer command under windows. For more information, please follow other related articles on the PHP Chinese website!

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