At the time of this writing, the latest openSUSE Leap 15.4 ships with PHP version 7.4 and 8.0. Likewise the upcoming release Leap 15.5 also including the PHP version 8.0. The latest popular PHP frameworks like Laravel (version 10) and Symfony (version 6.2), require minimal version 8.1, so we need to add the additional repository that packages PHP version 8.1.

PHP8 Package in Leap 15.5 Beta

We will use the devel:languages:php repository in OBS. Add the repository with the following command:

# openSUSE Leap 15.4
sudo zypper addrepo -p 90 https://download.opensuse.org/repositories/devel:languages:php/openSUSE_Leap_15.4/devel:languages:php.repo

#  openSUSE Leap 15.5
sudo zypper addrepo -p 90 https://download.opensuse.org/repositories/devel:languages:php/openSUSE_Leap_15.5/devel:languages:php.repo

# refresh the repo
sudo zypper refresh

If you have installed the PHP packages in your system, you have to execute the dup command in zypper. Like in my case that PHP 8.0 packages have been installed in the system, so I execute the following command:

sudo zypper dup --allow-vendor-change
Change the vendor to upgrade PHP 8.1

If your system has no PHP packages installed, you can install the PHP packages with the zypper install command.

sudo zypper install php8 php8-cli

Install Symfony 6.2

Before installing Symfony 6.2, we need install the required PHP modules:

sudo zypper install php8 php8-cli php8-mysql php8-sqlite php8-gd php8-curl php8-intl php8-mbstring php8-openssl php8-phar php8-fileinfo php8-tokenizer php8-dom php8-xmlwriter php8-ctype php8-iconv php8-zip php8-xsl php8-sodium php8-pgsql

Symfony Framework also need PHP Composer, following these steps to install it:

wget https://getcomposer.org/installer -O - -q | php -- --quiet
sudo mv composer.phar /usr/local/bin/composer

We will use Symfony CLI, a tool to help you build, run, and manage the Symfony applications directly from terminal.

wget https://get.symfony.com/cli/installer -O - | bash
ln -s ~/.symfony5/bin/symfony ~/bin/symfony

Checking the system if it meets all requirements with the symfony check:requirements command:

$ symfony check:requirements

Symfony Requirements Checker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> PHP is using the following php.ini file:
/etc/php8/cli/php.ini

> Checking Symfony requirements:
 [OK]
 Your system is ready to run Symfony projects

Now you are ready to install Symfony framework. Run the following command to create a new Symfony application:

symfony new myapp --version="6.2.*" --webapp

The command above creates the application in a new directory called myapp, Feel free to rename that with whatever you want your application to be named. The --webapp option installs all the packages that you usually need to build web applications.

Run the symfony server:start command to start Symfony server:

$ cd myapp
$ symfony server:start
[OK] Web server listening                                                                                                    The Web server is using PHP CLI 8.1.19                                                                                  http://127.0.0.1:8000

Open your browser and navigate to http://localhost:8000/. If everything is working, you’ll see a welcome page. Have fun 🥳


Update:

The php81 packages have been included in the openSUSE 15.5 repository. You can directly install PHP 8.1 and modules with zypper:

sudo zypper install php81 php81-cli php81-mysql php81-sqlite php81-gd php81-curl php81-intl php81-mbstring php81-openssl php81-phar php81-fileinfo php81-tokenizer php81-dom php81-xmlwriter php81-ctype php81-iconv php81-zip php81-xsl php81-sodium php81-pgsql

Leave a comment

Leave a Reply