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

shiro_'s avatar

Laravel Docker Specifying PHP Version

Hi, I am trying to dockerize my laravel app, but i have been having a challenge installing dependancies because it seems like i am using php 8 despite the fact that is specified version 7.4. I keep getting this error:

Problem 1
    - Root composer.json requires php ^7.1.3 but your php version (8.0.5) does not satisfy that requirement.
  Problem 2
    - laravel/framework[v5.7.0, ..., 5.7.x-dev] require php ^7.1.3 -> your php version (8.0.5) does not satisfy that requirement.
    - Root composer.json requires laravel/framework 5.7.* -> satisfiable by laravel/framework[v5.7.0, ..., 5.7.x-dev].

My code looks like this :

deploy-staging:
    name: Deploy Porject To STAGING Server
    runs-on: ubuntu-latest
    needs: [build-js-staging, app-tests]
    if: github.ref == 'refs/heads/staging'  
    steps: 
      - uses: actions/checkout@v1
      - name: Fetch built assets from Artefacts
        uses: actions/download-artifact@v1
        with:
          name: assets
          path: public
      - name: Setup PHP    
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4'
          extension-csv: mbstring, bcmath
      - name: Composer install
        run: composer install --ignore-platform-reqs

I tried deleting the composer.lock file, doing composer install like this composer install --ignore-platform-reqs and adding the following to my composer.json file with no success :

"require": {
    "php": "^7.3|^8.0",
    .....
},

Any advise /recommendations will be highly appreciated.

0 likes
1 reply
shiro_'s avatar
shiro_
OP
Best Answer
Level 1

This worked for me :

runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        operating-system: [ubuntu-latest] // you can add multiple operating systems
        php-versions: ['7.3'] // you can add multiple versions
    name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

    steps:
    - uses: actions/checkout@v2
    - name: Checkout
      uses: actions/checkout@v2
    - name: Install PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-versions }}
        extensions: intl #optional
        ini-values: "post_max_size=256M" #optional
    - name: Check PHP Version
      run: php

1 like

Please or to participate in this conversation.