How to run composer from anywhere?

0 votes
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, when I try to run the same from other folder I get Could not open input file: composer.phar.

How to call php composer.phar from every where without problems?
Oct 19 in PHP by kartik
• 35,300 points
36 views

1 answer to this question.

0 votes

Since Composer works with the current working directory it is possible to install it in a system wide way.

  • Change into a directory in your path like cd /usr/local/bin
  • Get Composer curl -sS https://getcomposer.org/installer | php
  • Make the phar executable chmod a+x composer.phar
  • Change into a project directory cd /path/to/my/project
  • Use Composer as you normally would composer.phar install
  • Optionally you can rename the composer.phar to composer to make it easier

Sometimes you can't or don't want to download at /usr/local/bin (some have experienced user permissions issues or restricted access), in this case you can try this

answered Oct 19 by Niroj
• 76,540 points

Related Questions In PHP

0 votes
1 answer

How to get thumbnail of youtube video from youtube API?

Hii @kartik, If you want the biggest image ...READ MORE

answered Apr 1 in PHP by Niroj
• 76,540 points
504 views
0 votes
1 answer

How to install a specific version of package using Composer?

Hello, Just use php composer.phar require For example : php ...READ MORE

answered Apr 1 in PHP by Niroj
• 76,540 points
927 views
0 votes
0 answers
0 votes
1 answer

How to override trait function and call it from the overridden function?

Hello, If the class implements the method directly, ...READ MORE

answered Apr 7 in PHP by Niroj
• 76,540 points
491 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 76,540 points
3,441 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 76,540 points
411 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 76,540 points
281 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 76,540 points
4,142 views
0 votes
1 answer

How To Run PHP From Windows Command Line in WAMPServer

Hello @kartik, Try using batch file Open notepad type php -S ...READ MORE

answered Oct 27 in PHP by Niroj
• 76,540 points
26 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27 in PHP by Niroj
• 76,540 points
154 views