12

I tried to install composer via PHP command like said in getcomposer site,
But the bash throw an error:

 bash: php: command not found

So I did a search in google , and I came up with some answers, 1) to add php binary file path to $PATH variable
The problem is when I run:

 find / -name php -type f

I get this error:

find: ‘/run/user/1000/gvfs’: Permission denied

Even with sudo and as a root

2) To install tht php-cli package, so I run

 pacman -S php7-cli

But I get this error:

error: target not found: php7-cli

So what it isn't working for me?

I installed php via XAMPP installer and I', using manjaro

2 Answers 2

31

Whenever you install XAMPP, you get all of the Apache, MySQL, PHP stack. The problem is, XAMPP won't link binaries to your PATH, because your could have another version of that software already installed.

Composer needs a PHP version available on your PATH, so the easier option is to link your already installed version of PHP.

I think you can find your PHP binary in /opt/lampp/bin so you can link it this way:

sudo ln -s /opt/lampp/bin/php /usr/bin/php

Hope it works!

If you want to double check your PHP binary location you can go to files then at the end you can find "other locations" click it and then go and check it.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, it works, just edit your answer , its lampp not lamp, sorry I can't vote you, but I'll mark you answert as accepted
It's works for me! Just correct the "llamp" to "lamp" :)
i have installed nginx then how can i solve php:command not found issue
I have installed php72 and by doing sudo ln -s /usr/bin/php72 /usr/bin/php it works like a charm.
1

You may be mixing up linux distributions.

php-cli is, I believe from debian-based distributions.

If you are using manjaro, check this wiki page for how to install php:

https://wiki.archlinux.org/index.php/PHP

Note that arch linux and manjaro are rolling releases, so it will install php7. Many things you find on the web are for lower versions, so be careful!

2 Comments

I already installed php via xampp , do I need to reinstall it? if yes do I need to remove xampp? do I also need to install apache and mysql ?
as @fedeisas says, if you install xampp, you install "Apache distribution containing MySQL, PHP and Perl." - it is focused on the web server. Thus, it is not available on the command line with the php command. It is not clear from you question why you need php composer; there is a reason why "XAMPP won't link binaries to your PATH", so if you need php on the command line, you should consider installing the php package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.