PhotoboothProject / photobooth

OpenSource Photobooth Webinterface
https://photoboothproject.github.io
MIT License
295 stars 62 forks source link

[Info] PHP7 support dropped - PHP8.2 required! #276

Open andi34 opened 1 year ago

andi34 commented 1 year ago

Edit 02.10.2023

polyfill isn't enough anymore, PHP 8.2 and Node.js v18 are required now

PHP7 reached EOL and won't receive any updates anymore.

While preparing the next release we decided, also in favor of upcoming features, to require PHP8 by default.

User of PHP7 must upgrade to latest PHP8 as soon as possible to retain compatibility with latest Photobooth.

As a workaround for now, user are able to add a Polyfill for needed PHP 8 functions. Place the polyfill inside private/lib of your Photobooth installation folder (default: /var/www/html) with the filename polyfill.php. The private/lib/polyfill.php is automatically used if exists.

<?php
//
// source: Laravel Framework
// https://github.com/laravel/framework/blob/8.x/src/Illuminate/Support/Str.php

if (!function_exists('str_starts_with')) {
    function str_starts_with($haystack, $needle) {
        return (string)$needle !== '' && strncmp($haystack, $needle, strlen($needle)) === 0;
    }
}

if (!function_exists('str_ends_with')) {
    function str_ends_with($haystack, $needle) {
        return $needle !== '' && substr($haystack, -strlen($needle)) === (string)$needle;
    }
}

if (!function_exists('str_contains')) {
    function str_contains($haystack, $needle) {
        return $needle !== '' && strpos($haystack, $needle) !== false;
    }
}
?>
andi34 commented 1 year ago

Update Apache Webserver

sudo apt install apt-transport-https lsb-release ca-certificates software-properties-common -y
sudo wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update
sudo apt install php8.2 php8.2-cli libapache2-mod-php8.2 -y
sudo apt install php8.2-{xml,zip,gd,mbstring} -y
sudo a2dismod php7.4
sudo a2enmod php8.2
sudo service apache2 restart
sudo gpasswd -a www-data plugdev
sudo gpasswd -a www-data video
sudo gpasswd -a www-data www-data
sudo reboot

For reference: https://php.watch/articles/install-php82-ubuntu-debian

mart-e commented 1 year ago

Hi,

I see you have just changed with 644833da5d33b0b7d2aec04a874e8d0b54367974 but this does not seem to work with my latest install of bullseye on raspberry pi

### Photobooth needs some software to run.
### Installing NGINX Webserver...
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances... Fait
Lecture des informations d'état... Fait      
E: Impossible de trouver le paquet php8.2
E: Impossible de trouver de paquet correspondant à l'expression rationnelle « php8.2 »
E: Impossible de trouver le paquet php8.2-fpm
E: Impossible de trouver de paquet correspondant à l'expression rationnelle « php8.2-fpm »

Sorry in French but it says "impossible to find package php8.2"

Reading the commit, I see it was supposed to add a new source but the file /etc/apt/sources.list.d/php.list is not created (not sure if failed before or skipped the if)

I manually made the two commands to add the new source files and the install was now successful :)

andi34 commented 1 year ago

Maybe missing some packages

Does it work if you run

sudo apt install apt-transport-https lsb-release ca-certificates software-properties-common -y
sudo wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
andi34 commented 1 year ago

https://github.com/PhotoboothProject/photobooth/commit/619dfae15ca2785cf3cb0da7b132728a71f22f59

Was called after webserver install, must be added earlier. Also made sure needed packages are installed.

Gambit359 commented 11 months ago

Hallo,

i tried to install on a rasberry pi (new and clean OS) with install-photobooth.sh. Here i got a problem with php-dom. It says something like "for this package there ist no installation ..." ("Für Paket php-dom existiert kein installationskandidat"). I changed in the COMMON_PACKAGES section of install-photobooth.sh php-dom to php8.2-dom and it seems to work on this section. Then i got other errors, but maybe i can figure this out for myself.

andi34 commented 11 months ago

php-xml instead

andi34 commented 10 months ago

https://php.watch/articles/install-php82-ubuntu-debian