I had to lower the PHP version in Docker + Composer + Laravel environment

Conclusion

composer.json


"platform": 
{
    "php": "7.3" #Put the version you want
}

And run composer update

FROM php:7.3-fpm-buster

Rewrite to docker-compose up -d OK

background

I had to change the PHP of the Laravel environment that was already running from 7.4 to 7.3 I manage the library with composer, but it doesn't work if I just set the container image to 7.3. I get an error like this

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - This package requires php ^7.4.0 but your PHP version (7.3.24) does not satisfy that requirement.

Details

environment

Docker

FROM php:7.4-fpm-buster
//The following is omitted

To

FROM php:7.3-fpm-buster
//The following is omitted

I want to move

Method

1 composer.json added

composer.json


"platform": 
{
    "php": "7.3" #Put the version you want
}

And run composer update


### 2 Erase the docker image

```
docker-compose down --rmi all --volumes
```

Do

### 3 Docker File rewrite

```dockerfile
FROM php:7.4-fpm-buster
//The following is omitted
```

To

```dockerfile
FROM php:7.3-fpm-buster
//The following is omitted
```
Rewrite

### 4 build

```docker-compose up -d --build```Run
Then what?

```
$ docker-compose exec php bash
$ hoge@fugafugab5318:/var/www/html# php -v
PHP 7.3.24 (cli) (built: Nov 18 2020 10:14:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies 
```

that's all


Recommended Posts

I had to lower the PHP version in Docker + Composer + Laravel environment
Just install Laravel8 on docker in PHP8 environment
What I was addicted to when updating the PHP version of the development environment (Docker) from 7.2.11 to 7.4.x
Build Docker + Laravel PHP + Vue.js development environment in 5 minutes
Install by specifying the version of Django in the Docker environment
What I did in the version upgrade from Ruby 2.5.2 to 2.7.1
I tried to build the environment little by little using docker
I tried to build the environment of WSL2 + Docker + VSCode
Install laravel/Dusk in docker environment (laravel6)
I tried to build the environment of PlantUML Server with Docker
I want to display the images under assets/images in the production environment
[Rails] How to reset the database in production environment (Capistrano version)
I tried to build a laravel operating environment while remembering Docker
I was able to deploy the Docker + laravel + MySQL app to Heroku!
Problems I was addicted to when building the digdag environment with docker
I tried to build a Firebase application development environment with Docker in 2020
I tried migrating the portfolio created on Vagrant to the Docker development environment
How to check the logs in the Docker container
[Rails] I tried to raise the Rails version from 5.0 to 5.2
A memo to prepare a laravel project in a specified position via composer on docker
Docker × Laravel HTTPS (SSL) communication in local environment
I want to get the value in Ruby
I was addicted to the NoSuchMethodError in Cloud Endpoints
I want to embed any TraceId in the log
I get Mysql2 :: Error :: ConnectionError in the production environment
I tried to summarize the state transition of docker
I tried installing the Docker Integration plugin in IntelliJ
Command memo to install xeyes in ubuntu docker environment
SSL in the local environment of Docker / Rails / puma
I tried to implement the Euclidean algorithm in Java
Make the strongest Laravel development environment (Docker) Japan time
Debug the VSCode + Docker + PHP development environment with XDebug.
I tried to build an environment using Docker (beginner)
I built an environment to execute unit tests using Oracle database (oracle12c) on the Docker in Docker (dind) image of GitLab-CI.
I tried using Docker because I don't want to pollute the local environment in Microsoft Teams tab development of MS Learn
Build Docker + Laravel PHP + Vue.js development environment in 5 minutes
Why you need setters / getters in the first place
[Rails 6.0, Docker] I tried to summarize the Docker environment construction and commands necessary to create a portfolio
I tried to develop the cache function of Application Container Cloud Service in the local environment
I want to recreate the contents of assets from scratch in the environment built with capistrano
I can't find the docker image after updating to docker desktop 2.4.0.0
I want to set the conditions to be displayed in collection_check_boxes
Host specification when laravel php artisan serve in docker container
Setting the baseURL in the axios module of Docker environment Nuxt
I tried to create React.js × TypeScript × Material-UI on docker environment
I want to transition to the same screen in the saved state
I want to narrow down the display of docker ps
I tried to create a padrino development environment with Docker
[Docker context] ~ How to access docker in remote environment from VScode ~
I want to simplify the conditional if-else statement in Java
After learning Progate, I tried to make an SNS application using Rails in the local environment
How to lower java version
I tried the Docker tutorial!
Use MailHog for checking emails in the development environment (using Docker)
I tried to summarize the words that I often see in docker-compose.yml
[Beginner] Procedure to log in to the virtual environment built with Vagrant
I tried to illuminate the Christmas tree in a life game
I tried to sort the data in descending order, ascending order / Rails
Super beginner builds Rails6 + Postgresql environment with Docker to the end
What I did in the migration from Spring Boot 1.4 series to 2.0 series
Build a browser test environment using Capybara in the Docker development environment
Install lsb_release from the command line when lsb_release fails in docker environment