How to run composer from anywhere?

前端 未结 10 1466
名媛妹妹
名媛妹妹 2020-12-04 07:51

I have just installed composer in my /usr/bin folder, so when from that folder I run php composer.phar I get the help info about composer. But, whe

相关标签:
10条回答
  • 2020-12-04 08:14

    composer.phar can be ran on its own, no need to prefix it with php. This should solve your problem (being in the difference of bash's $PATH and php's include_path).

    0 讨论(0)
  • 2020-12-04 08:20

    How to run Composer From Anywhere (on MacOS X) via Terminal

    Background:

    Actually in getComposer website it clearly states that, install the Composer by using the following curl command,

    curl -sS https://getcomposer.org/installer |php
    

    And it certainly does what it's intended to do. And then it says to move the composer.phar to the directory /usr/local/bin/composer and then composer will be available Globally, by using the following command line in terminal!

    mv composer.phar /usr/local/bin/composer
    

    Question:

    So the problem which leads me to Google over it is when I executed the above line in Mac OS X Terminal, it said that, Permission denied. Like as follows:

    mv: rename composer.phar to /usr/local/bin/composer: Permission denied
    

    Answer:

    Following link led me to the solution like a charm and I'm thankful to that. The thing I just missed was sudo command before the above stated "Move" command line. Now my Move command is as follows:

    sudo mv composer.phar /usr/local/bin/composer
    Password:
    

    It directly prompts you to authenticate yourself and see if you are authorized. So if you enter a valid password, then the Moving will be done, and you can just check if composer is globally installed, by using the following line.

    composer about
    

    I hope this answer helped you to broaden your view and finally resolve your problem.

    Cheers!

    0 讨论(0)
  • 2020-12-04 08:21

    For MAC and LINUX use the following procedure:

    Add the directory where composer.phar is located to you PATH:

    export PATH=$PATH:/yourdirectory
    

    and then rename composer.phar to composer:

    mv composer.phar composer
    
    0 讨论(0)
  • 2020-12-04 08:22

    Just move it to /usr/local/bin folder and remove the extension

    sudo mv composer.phar /usr/local/bin/composer
    
    0 讨论(0)
提交回复
热议问题