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, 2020 in PHP by kartik
• 37,490 points
273 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, 2020 by Niroj
• 82,560 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, 2020 in PHP by Niroj
• 82,560 points
663 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, 2020 in PHP by Niroj
• 82,560 points
1,697 views
0 votes
0 answers
0 votes
2 answers

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

instead of: return traitcalc($v); use this: ...READ MORE

answered Dec 13, 2020 in PHP by Uncle Nick
819 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, 2020 in Laravel by Niroj
• 82,560 points
5,513 views
0 votes
1 answer

What is redirection in Laravel?

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

answered Mar 18, 2020 in Laravel by Niroj
• 82,560 points
641 views
0 votes
1 answer

How to install Laravel via composer?

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

answered Mar 23, 2020 in Laravel by Niroj
• 82,560 points
490 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, 2020 in Laravel by Niroj
• 82,560 points
6,110 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, 2020 in PHP by Niroj
• 82,560 points
115 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, 2020 in PHP by Niroj
• 82,560 points
276 views