Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jaddz's avatar
Level 1

PHP81 and composer

New to laravel. Was building my platform on Amazon Linux AMI. Installed Apache and php 8.1 running php requires using the command php81 not php. So when I came to install composer i ran the install commands from the composer website with php81 instead of php.

e.g. 'php81 composer-setup.php' instead of 'php composer-setup.php'

now when I run composer it tells me php no such file or directory. Im guessing this is because composer is trying to look for php and not php81???

Can anyone help in this regard?

Thanks,

0 likes
5 replies
Snapey's avatar

Because composer cannot be found in your path.

Did you follow this step;

Most likely, you want to put the composer.phar into a directory on your PATH, so you can simply call composer from any directory (Global install), using for example:

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

For details, see the instructions on how to install Composer globally. https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md

jaddz's avatar
Level 1

Hey Snapey.

Thanks for that. I was sure I had done that. but off the back of your comment I went ahead and redid the composer install steps.

php81 -r "copy(getcomposer.org/installer', 'composer-setup.php');"

php81 -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php81 composer-setup.php

php81 -r "unlink('composer-setup.php');"

I then followed that with... sudo mv composer.phar /usr/local/bin/composer

this again resulted in ... /usr/bin/env: php: No such file or directory

so I cd to the /usr/local/bin directory. ls and can see composer try composer and get the same error. Seems like something else is going on.

But thanks for your help!

Snapey's avatar

sounds like you need a symlink to alias php to php81

1 like
jaddz's avatar
Level 1

Thanks again snapey. I did a bit more reading and digging and laravel install can be run within the local composer install directory using.

php81 composer.phar create-project laravel/laravel 'project name'

im in a big learning curve =] and no doubt will have more posts around here.

jaddz's avatar
Level 1

But yes I agree. I think if you symlink so composer thinks php81 is php it may also work. I might try this and confirm

Please or to participate in this conversation.