Is there any way to install Composer globally on Windows?

后端 未结 13 1493
予麋鹿
予麋鹿 2020-11-30 18:32

I\'ve read the global installation documentation for Composer, but it\'s for *nix systems only:

curl -s https://ge         


        
相关标签:
13条回答
  • 2020-11-30 18:59

    sorry to dig this up, I just want to share my idea, the easy way for me is to rename composer.phar to composer.bat and put it into my PATH.

    0 讨论(0)
  • 2020-11-30 19:07

    Unfortunately, all the good answers here didn't work for me. So after installing composer on windows 10, I just had to set system variable in environment variables and it worked.

    0 讨论(0)
  • 2020-11-30 19:07

    you can install it using this command line

     echo @php "%~dp0composer.phar" %* > composer.bat
    
    0 讨论(0)
  • 2020-11-30 19:08

    An alternative variant (see Lusitanian answer) is to register .phar files as executable on your system, exemplary phar.reg file:

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\.phar]
    @="phar_auto_file"
    
    [HKEY_CLASSES_ROOT\phar_auto_file\shell\open\command]
    @="\"c:\\PROGRA~1\\php\\php.exe\" \"%1\" %*"
    

    Just replace the path to php.exe to your PHP executable. You can then also extend the %PATHEXT% commandline variable with .PHAR which will allow you to type composer instead of composer.phar as long as composer.phar is inside the %Path%.

    0 讨论(0)
  • 2020-11-30 19:09

    Sure. Just put composer.phar somewhere like C:\php\composer.phar, then make a batch file somewhere within the PATH called composer.bat which does the following:

    @ECHO OFF
    php "%~dp0composer.phar" %*
    

    The "%*" repeats all of the arguments passed to the shell script.

    Then you can run around doing composer update all ya want!

    0 讨论(0)
  • 2020-11-30 19:09

    A bit more generic if you put the batch in the same folder as composer.phar:

    @ECHO OFF
    SET SUBDIR=%~dp0
    php %SUBDIR%/composer.phar %*
    

    I'd write it as a comment, but code isn't avail there

    0 讨论(0)
提交回复
热议问题