lando / php

The Official Lando PHP plugin.
https://docs.lando.dev/php
GNU General Public License v3.0
14 stars 15 forks source link

Add PHP 8.3 support #77

Closed kaszarobert closed 7 months ago

kaszarobert commented 8 months ago

Soon a new version of PHP will be released. Although, it is not yet stable but it would be good to add a possibility to use that in Lando even before a stable release.

Until that, we have to use a custom Docker image. Here's what we've been using recently to test out webapps and Drupal sites manually under PHP 8.3 RC4 with Apache + with working xdebug (also using xdebug mode toggle script from https://github.com/lando/lando/issues/1668#issuecomment-772829423):

.lando.yml

name: drupal1083
recipe: drupal10
config:
  webroot: web
  php: '8.2' # Fake the version to prevent Lando errors but the correct version will be set in a custom image.
  database: mysql:8.0
  xdebug: off
  composer_version: '2'
  config:
    php: .lando/php.ini

services:
  appserver:
    scanner: false
    overrides:
      image: 'custom/php:8.3.0RC4-apache-bullseye'
      build: ./.lando/php
      environment:
        # Support debugging Drush with XDEBUG.
        PHP_IDE_CONFIG: "serverName=appserver"
        XDEBUG_MODE:

  database:
    creds:
      user: drupal1083
      password: drupal1083
      database: drupal1083

  phpmyadmin:
    scanner: false
    type: phpmyadmin:5.1
    hosts:
      - database

proxy:
  appserver:
    - drupal1083.localhost
  phpmyadmin:
    - pma.drupal1083.localhost

tooling:
  xdebug:
    description: Loads Xdebug in the selected mode.
    cmd:
      - appserver: /app/.lando/xdebug.sh
    user: root

.lando/php/Dockerfile

# docker build -t custom/php:8.3.0RC4-apache-bullseye .

FROM php:8.3.0RC4-apache-bullseye

# Install dependencies we need
RUN mkdir -p /usr/share/man/man1 /usr/share/man/man7 \
  && apt -y update && apt-get install -y \
    gnupg2 \
    wget \
  && echo 'deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main' >> /etc/apt/sources.list.d/pgdg.list \
  && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
  && apt-get update && apt-get install -y \
    bzip2 \
    default-mysql-client \
    exiftool \
    git-core \
    imagemagick \
    libbz2-dev \
    libc-client-dev \
    libfreetype6-dev \
    libicu-dev \
    libjpeg62-turbo-dev \
    libkrb5-dev \
    libldap2-dev \
    libmagickwand-dev \
    libmemcached-dev \
    libpng-dev \
    libpq-dev \
    libssl-dev \
    libwebp-dev \
    libxml2-dev \
    libzip-dev \
    libonig-dev \
    openssl \
    postgresql-client-10 \
    pv \
    rsync \
    ssh \
    unzip \
    wget \
    xfonts-75dpi \
    xfonts-base \
    zlib1g-dev

RUN pecl install apcu \
  && pecl install imagick \
  && pecl install memcached \
  && pecl install oauth \
  && pecl install redis-5.3.7 \
#  && pecl install xdebug \
  && docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu/ \
  && docker-php-ext-enable apcu \
  && docker-php-ext-enable imagick \
  && docker-php-ext-enable memcached \
  && docker-php-ext-enable oauth \
  && docker-php-ext-enable redis \
  && docker-php-ext-install bcmath \
  && docker-php-ext-install bz2 \
  && docker-php-ext-install calendar \
  && docker-php-ext-install exif \
  && docker-php-ext-install gettext \
  && docker-php-ext-install intl \
  && docker-php-ext-install ldap \
  && docker-php-ext-install mbstring \
  && docker-php-ext-install mysqli \
  && docker-php-ext-install opcache \
  && docker-php-ext-install pcntl \
  && docker-php-ext-install pdo \
  && docker-php-ext-install pdo_mysql \
  && docker-php-ext-install pdo_pgsql \
  && docker-php-ext-install soap \
  && docker-php-ext-install zip \
  && php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
  && php composer-setup.php --install-dir=/usr/local/bin --filename=composer --version=2.2.18 \
  && php -r "unlink('composer-setup.php');" \
  && chsh -s /bin/bash www-data && mkdir -p /var/www/.composer && chown -R www-data:www-data /var/www \
  && apt-get -y clean \
  && apt-get -y autoclean \
  && apt-get -y autoremove \
  && rm -rf /var/lib/apt/lists/* && rm -rf && rm -rf /var/lib/cache/* && rm -rf /var/lib/log/* && rm -rf /tmp/* \
  && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
  && docker-php-ext-install imap \
  && docker-php-ext-configure gd --enable-gd --with-jpeg --with-webp --with-freetype \
  && docker-php-ext-install gd

# While there's no xdebug release for PHP 8.3, we need to install it from source.
# As soon as we can install with PECL, remove this RUN and uncomment the previous 
# pecl install xdebug line.
RUN apt-get install -y git \
    && git clone https://github.com/xdebug/xdebug.git \
    && cd xdebug \
    && phpize \
    && ./configure \
    && make \
    && make install \
    && cd .. \
    && docker-php-ext-enable xdebug

RUN curl https://dl.yarnpkg.com

.lando/php.ini

memory_limit = 256M

; Xdebug settings required for PhpStorm.
; https://github.com/lando/lando/issues/1668#issuecomment-772829423
xdebug.start_with_request = yes
xdebug.log_level=0

.lando/xdebug.sh

#!/bin/bash

if [ "$#" -ne 1 ]; then
  echo "Xdebug has been turned off, please use the following syntax: 'lando xdebug <mode>'."
  echo "Valid modes: https://xdebug.org/docs/all_settings#mode."
  echo xdebug.mode = off > /usr/local/etc/php/conf.d/zzz-lando-xdebug.ini
  /etc/init.d/apache2 reload
else
  mode="$1"
  echo xdebug.mode = "$mode" > /usr/local/etc/php/conf.d/zzz-lando-xdebug.ini
  /etc/init.d/apache2 reload
  echo "Xdebug is loaded in "$mode" mode."
fi
klonos commented 7 months ago

8.3.0 stable was released last week: https://www.php.net/ChangeLog-8.php#8.3.0

kaszarobert commented 7 months ago

There are still no official PHP images which is used in Lando PHP for 8.3.0, only for 8.3.0-RC6. Hopelly, they will publish one ASAP and we can have a MR.

pfrenssen commented 7 months ago

Images have been tagged!

emircanerkul commented 5 months ago

@reynoldsalec I got the latest Lando but can't install it because this issue is not just a PHP update. Php 8.3 update for Drupal 10 recipe.

ERROR ==> drupal-php version 8.3 is not supported
reynoldsalec commented 5 months ago

@emircanerkul this change hasn't been deployed yet to the installer release of Lando, but you can either do a custom install of the PHP plugin (make sure to use the instructions in the "Docker" tab) OR you can try out the pre-release of Lando v3.21 that has a lando update command that will update your plugins to their latest versions. Note that release is currently alpha, so YMMV; you can read the extended release notes here: https://lando.dev/blog/2024/01/16/v321-extended.html

eldair commented 5 months ago

@reynoldsalec I've tried following custom install of php plugin for docker (in wsl) but the plugin never got installed. Why is this still not released, it had been 2 months already?

EDIT: I managed to manually install php plugin (in wsl w/o docker) but when trying to start php8.3 I get the following error:

Error response from daemon: manifest for devwithlando/php:8.3-fpm-4 not found: manifest unknown: manifest unknown

emircanerkul commented 5 months ago

https://www.reddit.com/r/learnprogramming/comments/165i43p/is_php_dead/

emircanerkul commented 5 months ago

Hi @reynoldsalec

I installed the latest and did an update

@lando/php ⚠ Update available https://github.com/lando/php/releases/tag/v1.1.0

But my problem is ERROR ==> drupal-php version 8.3 is not supported not just related to lando/php package. I think lando/drupal package should be updated accordingly.

tvlooy commented 5 months ago

@pfrenssen while it seems like you added devwithlando/php:8.3-apache-4, it does not appear in https://hub.docker.com/r/devwithlando/php/tags?page=1&name=8.3

It looks like something is not right in your github actions file. It seems like it's only building php 7.3 https://github.com/lando/php/actions/runs/7186820860/job/19573056931

As you can see https://hub.docker.com/r/devwithlando/php/tags?page=1&name=7.3 is updated a few hours ago, but https://hub.docker.com/r/devwithlando/php/tags?page=1&name=8.2 is updated 9 months ago, and 8.3 is not in there.

kaszarobert commented 5 months ago

I opened a new issue for this deploying problem.

reynoldsalec commented 4 months ago

Note that the deployment issue should be fixed: https://github.com/lando/php/pull/101