Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

composer to use newer version of php

Tags:

How do i get composer to use a newer version of php i have installed? I have downloaded and am using php 5.4 in all my local servers but when i download composer it points to my mac's default #!/usr/local/bin/env version, which is 5.3.15. I tried editing the composer executable and change the php used but it broke the executable.

I'm trying to use composer to install Laravel and it is downloading the wrong version because of this.

This is what the top of my composer executable looks like but then there's a bunch of weird characters below.

#!/usr/bin/env php <?php /*  * This file is part of Composer.  *  * (c) Nils Adermann <[email protected]>  *     Jordi Boggiano <[email protected]>  *  * For the full copyright and license information, please view  * the license that is located at the bottom of this file.  */  Phar::mapPhar('composer.phar'); define('COMPOSER_DEV_WARNING_TIME', 1366931166); require 'phar://composer.phar/bin/composer'; 

composer.json for laravel project

{     "require": {         "laravel/framework": "4.0.*@dev"     },     "autoload": {         "classmap": [             "app/commands",             "app/controllers",             "app/models",             "app/database/migrations",             "app/database/seeds",             "app/tests/TestCase.php"         ]     },     "scripts": {         "post-update-cmd": "php artisan optimize"     },     "minimum-stability": "dev" } 
like image 866
David Avatar asked Mar 28 '13 02:03

David


People also ask

How do I update PHP version in composer json?

To update your packagesNavigate to the root of your git repo, where your composer. json file is. Run composer update (on your local machine) to update the required packages and re-generate a composer. lock file.

How do I switch between PHP versions?

You can do sudo update-alternatives --config php to set which system wide version of PHP you want to use. This makes your command line and apache versions work the same.

How do I update composer from version 1 to 2?

To change to version one run the self-update command and pass in the --1 flag. This will change composer to version one and now you can install your dependencies. Once you have installed your dependencies, now you can run the same command and pass in --2 as the flag and this will switch back to composer version 2.


1 Answers

If you don't care for permanent settings, below command worked for me:

/Applications/MAMP/bin/php/php5.6.27/bin/php /usr/local/bin/composer install 

Syntax is:

{PATH TO YOUR PHP VERSION} {PATH TO COMPOSER EXECUTABLE} {COMPOSER COMMAND} 

To know the executable path: which {EXECUTABLE} can be very helpful. Ex: which composer gave below output which I used in command above:

/usr/local/bin/composer 
like image 77
Diwaker Tripathi Avatar answered Oct 05 '22 14:10

Diwaker Tripathi