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,520 points
12,189 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,880 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,880 points
1,634 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,880 points
3,602 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
3,596 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,880 points
22,957 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,880 points
2,969 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,880 points
2,900 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,880 points
44,398 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,880 points
3,068 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,880 points
3,337 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP