Skip to main content

I installed Lando 3.6.2 and Laravel 9.  When I visit the web page, I getting

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.28. in /app/vendor/composer/platform_check.php on line 24

 

Problem solving

Opening the directory in VS Code, if I run the command 

php -v

The response I'm getting is

PHP 8.1.2 (cli) (built: Jan 21 2022 04:47:26) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Xdebug v3.1.3, Copyright (c) 2002-2022, by Derick Rethans
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

However, if I run the command

lando php -v

The response in this instance is

PHP 7.4.28 (cli) (built: Mar 11 2022 08:06:02) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies

Hmmm, an insight into the PHP version issue.  So my first step to resolving this conflict is to target the PHP version being used in Lando.

 

Editing the .lando.yml file

Currently my .lando.yml file has the following content:

name: laravel9
recipe: laravel
config:
  webroot: public

I'll change this by adding php version.  Reading through the documentation on the Lando doc site, there the recommendation is to apply the PHP version as follows:

services:
  myservice:
    type: php:8.0

So the complete file now has the following content

name: laravel9
recipe: laravel
config:
  webroot: public
services:
  myservice:
    type: php:8.0

Post this change you need to rebuild lando

lando rebuild

When I test the PHP version as I did previously, I'm continue to get 7.4.28.  So not the solution.  However, instead I'm going to try

php: '8.0'

So the .lando.yml file will look like

name: laravel9
recipe: laravel
config:
  webroot: public
  php: '8.0'

Post a lando rebuild, when I run the command lando php -v command, I'm now receiving the following response

PHP 8.0.16 (cli) (built: Mar 11 2022 06:28:41) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.16, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.16, Copyright (c), by Zend Technologies

 

Cross checking the site, it is now loading :)

 

Other config options for the .lando.yml file

Setting a composer version

config:
  composer_version: '2.0.7'

Choosing a webserver

By default the Laravel recipe will run an Apache 2.4. If you want to change this it again is as easy as adding it to the config section of the .lando.yml:

config:
  via: nginx:1.18

Setting a database

The default for the database is MySQL 5.7. However you can change this to MariaDB or Postgres in the config section of your .lando.yml:

config:
  database: mariadb

config:
  database: postgres:9.6

Whilst working with databases... what happens when you want to have a statis port?

services:
  database:
    portforward: 3307

For more details about how to add, read Connecting your Lando DB with an external MySQL app (Sequel Ace) on an local environment.

Setting a caching backend

By default the Laravel recipe does not include a caching service. You are able to easily add redis or memcached by adding it to the config section of the .lando.yml file:

config:
  cache: redis:2.8

config:
  cache: memcached

xdebug

config:
  xdebug: true

 

Related articles

Andrew Fletcher09 Nov 2023
Lando set-up running Drupal and Python
Lando is a development environment tool that makes it easier to set up and manage local development environments for web applications. To use Python within a Lando-based development environment, you can follow these general steps: Create a Lando Configuration FileMake sure you have a Lando...
Andrew Fletcher22 Oct 2023
Lando setup running Drupal 10
Create a Lando setup running Drupal 10.The command you provided appears to be a Lando configuration command for initialising a new Lando environment for a Drupal 10 project. Following is a breakdown of the command and what it does:# Initialize a new lando drupal using a vanilla Drupal 10...