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

thomthom's avatar

composer.lock for PHP 5.6?

I got a site that's still running PHP 5.6. I need to push a small update.

As part of the update I was working on I updated the composer.lock file because I had also updated from an old Homestead installation to a newer one.

My Homestead.yml got something like this to make Homestead operate with PHP 5.6:

sites:
    - map: mysite.local
      to:  /home/vagrant/mysite-local/public
      php: "5.6"

However, when I pushed to forge (staging for testing) I got a failure email:

Loading composer repositories with package information
Installing dependencies from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for doctrine/inflector v1.2.0 -> satisfiable by doctrine/inflector[v1.2.0].
    - doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
  Problem 2
    - doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
    - laravel/framework v5.2.45 requires doctrine/inflector ~1.0 -> satisfiable by doctrine/inflector[v1.2.0].
    - Installation request for laravel/framework v5.2.45 -> satisfiable by laravel/framework[v5.2.45].

So I appear to have updated composer.lock with packages that required PHP 7.

(I recently got a new computer, so I set up everything fresh - this time with PHP7 on my local system and a newer Homestead that supported multiple PHP versions.)

So my question now is, how can I regenerate composer.lock with a dependency set that's compatible with PHP 5.6?

(Also, how does it work with Homestead and sites you have set to PHP 5.6? When I SSH into the vagrant box, and cd into the project folder php -v yields PHP 7.1. Is it only when serving the website that PHP5.6 is used?)

-Thom

0 likes
3 replies
thomthom's avatar

I just realised that composer.json have an entry for required PHP version, and I tried to update that to stay on 5.6:

    "require": {
        "php": "~5.6.0",
        "laravel/framework": "5.2.*",
        "laravelcollective/html": "5.2.*",
        "bugsnag/bugsnag-laravel": "1.*"
    },

I had hoped that would lock dependencies to PHP 5.6, but I got an error while running composer update:

Your requirements could not be resolved to an installable set of packages.

So it appear to relate to the PHP version of my local environment and not the project's target environment.

Does that mean I have to have PHP 5.6 locally to be able to get this working? Or is there some other configuration to target the dependencies to PHP 5.6?

thomthom's avatar
thomthom
OP
Best Answer
Level 7

Update: I tried adding config/platform/php to composer.json - and that seemed to work. Running composer update appeared to downgrade dependencies.

    "config": {
        "platform": {
            "php": "5.6.5"
        },
        "preferred-install": "dist"
    }

But I still get error when I push to forge:

Generating autoload files
> php artisan clear-compiled
PHP Fatal error:  Declaration of Illuminate\Auth\SessionGuard::basic() must be compatible with Illuminate\Contracts\Auth\SupportsBasicAuth::basic($field = 'email', $extraConditions = Array) in /home/forge/staging.*****.com/bootstrap/cache/compiled.php on line 462

I see it originates from bootstrap/cache - so this this from some stale cache? Any way to clear it? Looks like its getting thrown by php artisan clear-compiled ... so then what?

thomthom's avatar

Ok - just to conclude my monologue of documenting my ramblings:

I ssh'd into forge and removed bootstrap/cache/compiled.php. Back in forge I hit Deploy again and this time it ran fine.

Production deployment then went fine. :D

Please or to participate in this conversation.