Skip to content

Welcome to the repository, which showcases some of the exciting features of PHP 8.1.

Notifications You must be signed in to change notification settings

MarioBlazek/php-81-features

Repository files navigation

The PHP 8.1 release

Welcome to this repository which showcases some of the interesting features of PHP 8.1.

Topics

  1. Enumerations
  2. Readonly properties
  3. Intersection types
  4. Fibers
  5. never return type
  6. final class constants
  7. First-class callable
  8. Array unpacking with string keys
  9. new keyword in initializer
  10. Other changes

Slides

Slides can be downloaded here.

PHP 8.1 environment

You can either install PHP 8.1 locally to run the code examples or use the provided helper script to run the examples inside Docker container.

Installing PHP 8.1

Add the ondrej/php repository to you Ubuntu machine:

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Install only cli package, it should be enough:

sudo apt install php8.1-cli

In case if you need to install some of the php extensions:

sudo apt install php8.1-[extname]

Installation of PHP 8.1 will set is as default PHP environment on your machine. To set the PHP 7.4 as the default environment, run the following commands:

sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set phar /usr/bin/phar7.4
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4

Running example in Docker container

Use the run helper script to run the code example inside Docker container:

./run.sh 01_enums/01_class_with_constants.php

Don't forget to add proper permissions to run.sh script:

chmod +x run.sh

NOTE: This repository was inspired by:

About

Welcome to the repository, which showcases some of the exciting features of PHP 8.1.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published