Over the last couple of days, I’ve been really struggling to try to get Composer to install a project on a CPanel server. As you know, Composer can also check environment constraints and for some reason  php -v would show PHP 7.1 but when running composer install or php composer install, it would say that I’m using PHP 5.6.

I tried using the full path to both PHP and Composer (to find that out, you can use which php and which composer) with no luck. After a bit of research, I finally found that EasyApache 4 (the system that manages Apache and PHP on CPanel servers) has the ability to pass an argument to the command allowing you to see the PHP version.

You can replace 56 with the specific version of PHP that you want like 70 for PHP 7.0.x or 71 for PHP 7.1.x. My new command looked like this:

It’s obviously important to run Composer with the version of PHP that your web server is running as it will install the dependencies with those constraints in mind.

Published by Seagyn

I'm a passionate "Maker of Things" and build as often as I can. I build things with mainly with PHP and a little Javascript. View more posts

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.