PHP Annotated – November 2023

PHP Annotated Monthly

Welcome to the November edition of PHP Annotated! In it, we look back over some of the most interesting developments in the PHP community during the past month, featuring handpicked news, articles, tools, and videos.

Highlights

  • 🎉 PHP 8.3.0 released!

    PHP 8.3 is a major update of the PHP language. It contains new features, such as typed class constants, deep-cloning of readonly properties, and additions to the random functionality. As always, it also includes performance improvements, bug fixes, and a general cleanup.

    For a detailed list of what’s new in PHP 8.3, check out the release page, the migration guide, and learn a little more about the release in the PHP Foundation’s announcement.

    Install or upgrade to PHP 8.3

    PhpStorm already supports PHP 8.3.

    Watch a 📺 Celebrating PHP 8.3 stream with Freek, Brent, and Roman.

  • ⚠️ PHP 8.0 has reached end of life

    PHP 8.0.30 marked the last release of PHP 8.0. It will no longer receive official security updates.

  • PHP 8.1.26 and PHP 8.2.13 have been released

    🐛 These are bug-fix releases.

    The PHP 8.1 branch will receive one more release, PHP 8.1.27, which will be the last bug-fix release, with only security bug fixes being released thereafter.

  • 🎂 The PHP Foundation turns two
    The PHP Foundation was established two years ago.

    Over the past year, the PHP Foundation has supported the work of six core developers, and made a significant contribution to the PHP language.

    Check out the PHP Foundation’s November 2023 Update.

    Consider supporting the PHP Foundation via OpenCollective or GitHub Sponsors.

PHP Core

Most of the Core news is covered in detail in the PHP Core Roundup series from the PHP Foundation, so we’ll only make a few brief mentions:

  • 📣 RFC: Resource to object conversion
    Resource is an obsolete data structure in PHP that has long since been superseded by objects. Work on replacing resources with objects started back in 2013, but most extensions only migrated with the release of PHP 8.0.

    Máté Kocsis suggests migrating the remaining extensions and defining a policy for future development.

  • 📣 RFC: Release cycle update
    Currently, the lifetime of a PHP version is 3 years. Many people consider this to be too short, and the pre-release phase, which is six months, excessively long.

    Jakub Zelenka, the PHP 8.3 release manager, proposes to increase the PHP version lifetime to 4 years (2 years of maintenance and 2 years of security updates) and to revise the pre-release phase.

  • 📣 RFC: Improve callbacks in ext/dom and ext/xsl
    Niels Dossche proposes to allow XSLTProcessor::registerPHPFunctions()` and `DOMXPath::registerPhpFunctions()` methods to use `callable.

  • 📣 RFC: Change how JIT is disabled by default
    Currently, JIT is running in tracing mode, but disabled by default when opcache.jit_buffer_size is set to 0. RFC suggests disabling JIT by default by setting opcache.jit=disable, and increasing the default jit_buffer_size value to 64m.

  • 📣 RFC: Final anonymous classes

    The RFC proposes one of the three options to improve experience with anonymous classes:

    1. Add support for final anonymous classes (new final class {} syntax, no breaking changes).
    2. OR Make all anonymous classes final by default, without the option to make them final (breaking change)
    3. OR Make all anonymous classes final by default, provide an optional `open` keyword to make them non-final (like in Kotlin, new open class {}, breaking changes).

  • 📣 RFC: Property Hooks
    In this RFC, Ilija Tovillo and Larry Garfield propose to declare virtual properties with get/set functions.

    The design and syntax is most similar to Kotlin, although it also draws influence from C# and Swift.

    class User implements Named
    {
        private bool $isModified = false;
     
        public function __construct(private string $first, private string $last) {}
     
        public string $fullName {
            get => $this->first . " " . $this->last;
     
            set($value) => [$this->first, $this->last] = explode(' ', $value);
        }
    }
    

    Interesting side effect of this RFC is that it allows to declare abstract properties in interfaces:

    abstract class A
    {
        abstract public string $readable { get; }
        abstract protected string $writeable { set; }
        abstract protected string $both { get; set; }   
    }
     
    class C extends A
    {
        public string $readable;
        protected string $readable;
        protected string $writeable {
            set => $field = $value;
        }
        public string $both;
    }
    

    Thanks to Sjon Hortensius, you can already try property hooks on 3v4l.org.

    And you can also provide your feedback on RFC Vote: Property Hooks.

Tools

  • php-tui/php-tui – A framework for creating console applications in PHP with pseudo graphical UI.
  • Crell/Serde – A robust serialization/deserialization library for PHP 8.
  • pestphp/pest-plugin-stressless – A stress load testing plugin for Pest built on top of grafana/k6. See the introductory video 📺 Stressless: Stress Testing for PHP.
  • buggregator/server – A lightweight, standalone server that offers a range of debugging features for PHP applications, including XHprof profiler, Symfony VarDumper server, SMTP server, Sentry-compatibile server, Monolog server, and HTTP requests dump server.

    It comes with buggregator/trap – a console mini-server and helper for more convenient debugging in PHP.

  • NoiseByNorthwest/php-spx – A simple and straight-to-the-point PHP profiling extension with its built-in web UI.
  • reliforp/reli-prof – A sampling profiler or a memory profiler for PHP written in PHP, which reads information about running PHP VM from outside the process. You can find performance bottlenecks or memory leaks in your scripts without changing the target script or loading extensions.

    Alternatively, you can try arnaud-lb/php-memory-profiler – A memory profiler extension for PHP. It helps find memory leaks in PHP scripts.

  • saloonphp/xml-wrangler – A simplistic PHP library designed to make reading and writing XML easy. See also veewee/xml – A package that provides all the tools you need for worry-free work with XML in PHP.
  • jolicode/JoliMarkdown – A syntax fixer for markdown content. Read Introducing JoliMarkdown for more details.
  • cerbero90/lazy-json – A framework-agnostic package to recursively load JSON files of any dimension and any source into Laravel lazy collections.
  • staabm/phpstan-baseline-analysis – Analyzes PHPStan baseline files and creates aggregated error trend-reports.
  • spiral/json-schema-generator – Provides the ability to generate JSON schemas from Data Transfer Object (DTO) classes.

Symfony

Laravel

Other Frameworks

Misc

Fun

Conferences

Check out these upcoming PHP gigs worth visiting and applying to present at:

If you’re wondering when the next PHP meetup near you is happening, Tomas Votruba has got you covered with his lovely friendsofphp.org meetup aggregator. There is also a calendar on php.net.


That’s all for today. Thanks for reading!

If you have any interesting or useful links to share via PHP Annotated, please leave a comment on this post or send us a tweet.

Subscribe to PHP Annotated


Roman Pronskiy

Developer Advocate at the @PhpStorm team, Operation Manager at @The PHP Foundation.

Twitter | GitHub

image description