Udders
Udders

Reputation: 6986

composer, laravel and 2 versions of PHP

I am having trouble getting composer and laravel to work nicely on my server,

if I run,

php composer.phar update

I get the following error,

Problem 1
- laravel/framework v4.2.9 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.8 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.7 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.6 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.5 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.4 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.3 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.2 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.11 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.10 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.1 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.0 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.11 requires php >=5.4.0 -> no matching package found.
- Installation request for laravel/framework 4.2.* -> satisfiable by laravel/framework[v4.2.0, v4.2.1, v4.2.10, v4.2.11, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].

Now I think this because php on my $PATH is pointing to /usr/local/bin and that version of PHP is 5.3, however I also have PHP 5.5.14 installed on my server, and I can point composer straight to that version like this,

/usr/local/php-5.5.14-cgi/bin/php composer.phar update

Then I get the following error,

PHP Parse error: syntax error, unexpected '[' in /var/www/vhosts/popsapp.com/api.popsapp.com/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 411 Script php artisan clear-compiled handling the post-update-cmd event returned with an error The disk hosting /var/www/vhosts/popsapp.com/.composer is full, this may be the cause of the following exception

                                                                                                [RuntimeException]                                                    

Error Output: PHP Parse error: syntax error, unexpected '[' in /var/www/vhosts/popsapp.com/a
pi.popsapp.com/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 411

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN]

Which leads my to believe that either composer or larvel is still using the wrong version of php, how can I make sure that the full installation uses PHP 5.5.14?

Upvotes: 1

Views: 2039

Answers (2)

Gauravbhai Daxini
Gauravbhai Daxini

Reputation: 2190

LARAVEL installation on Linux OS ubntu 14.04:

STEP 1 : Install latest PHP version

You can remove earlier php version by following command:

sudo apt-get purge php
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.1

STEP 2 : Install Composer

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
composer

STEP 3 : INSTALL LARAVEL 5.4

1] Go to your working project directory and run following commands:

composer create-project --prefer-dist laravel/laravel laravel_5.4
cd laravel_5.4
sudo chmod -R 777 /opt/lampp/htdocs/Gaurav/laravel_5.4
composer install

2] If you get fatal error while installing composer regrading mbstring use following command:

sudo apt-get install php-mbstring php7.1-mbstring php-gettext libapache2-mod-php7.1
composer update

3] To run laravel project

php artisan serve
php artisan key:generate

Go to http://127.0.0.1:8000 in your browser and you will see the home screen of laravel

Upvotes: 0

maxwilms
maxwilms

Reputation: 2024

During composer update, composer is calling the scripts in the composer.json file. For Laravel this file looks something like:

"scripts": {
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ]
},

So you can either update your composer.json to use the right version of PHP or just update your $PATH variable. I would suggest the later.

Upvotes: 2

Related Questions