News

PHP Annotated – June 2024

PHP Annotated
Welcome to the June edition of PHP Annotated! We’ll recap the most interesting developments in the PHP community over the past couple of months, featuring handpicked news, articles, tools, and videos.

Highlights

  • PHP 8.1.29, PHP 8.2.20, and PHP 8.3.8 released

    ❗️These security updates fix CVE-2024-4577, CVE-2024-5458, CVE-2024-5585, and vulnerability in openssl_private_decrypt() function known as the Marvin attack.

  • Happy 29th birthday, PHP!
    On June 8, PHP turned 29 years old! For a throwback, check out Rasmus Lerdorf’s initial public announcement of PHP.

    I published a video where I compiled and ran the very first version of the language. Witness what PHP was like 29 years ago:

    Here’s to many more years of empowering developers and pushing the boundaries of web technology. Happy Birthday, PHP! 🎉🥳🎂

  • PHP 8.4

    The next version of the language is shaping up nicely, and the first Alpha has already been tagged. Here’s what’s coming:

    • Property Hooks
    • new without parentheses
    • New DOM HTML5 support
    • Many new functions: array_find(), array_find_key(), array_any(), array_all(), grapheme_str_split(), DateTime(Immutable)::get/setMicrosecond(), DateTime(Immutable)::createFromTimestamp(), mb_ucfirst(), mb_lcfirst(), mb_trim(), mb_ltrim(), mb_rtrim(), http_(get|clear)_last_response_headers(), request_parse_body().

    And on top of that, there are many more cool tidbits. Here are a couple lesser-known ones:

  • How many PHP developers are there in the world?

    SlashData, a company specializing in developer surveys, has published a report assessing the demand for programming languages and predicting the size of programming language communities.

    According to the report, PHP ranks sixth with 9.8 million developers worldwide.

  • MySQL 9.0 is available
    There aren’t many new features in it, but the new VECTOR column type is probably the most notable one.

PHP Core

  • RFC: Add stream open functions to XML{Reader,Writer}
    Thanks to Niels Dossche, PHP 8.4 will have two new methods to create instances of the respective classes from an already open stream: XMLReader::fromStream(), XMLWriter::toStream().
  • 📣 RFC: Static Constructors
    Erick de Azevedo Lima suggests adding a new __staticConstruct() method to initialize static properties of a class before creating an instance.

    Erick demonstrates the current workarounds people use, including in Composer, and analyzes how other languages solve this problem. The suggested solution is inspired by C#.

  • 📣 RFC: Static class
    Paul Morris suggests adding a new type of class – static. A static class is declared with the static keyword, and all methods and properties of that class are automatically static.
  • 📣 RFC: Lazy Objects
    Arnaud Le Blanc and Nicolas Grekas propose adding lazy objects to PHP. These objects will be initialized and consume resources only when reading or modifying a property occurs.

    While lazy objects won’t be used directly by most users, they are primarily intended for library and framework authors, allowing them to remove a lot of boilerplate code.

  • 📣 RFC: Deprecations for PHP 8.4
    Niels Dossche, Gina Peter Banyard, Máté Kocsis, Tim Düsterhus, Kamil Tekiela, and Jorg Sowa have launched an RFC discussion to determine which functionality should be deprecated in PHP 8.4 and removed in PHP 9.0.

    Beware, it has a few controversial suggestions that might affect your projects. Such as deprecating uniqid(), md5(), sha1(), md5_file(), and sha1_file() functions. So if you disagree with the proposed changes, make sure to voice out your concerns on the mailing list.

PhpStorm

Tools

  • FrankenPHP v1.2.0 – This update of the PHP application server comes with a built-in Caddy 2.8 web server, support for full-duplex HTTP/1 connections, and other features.
  • buggregator/server – Buggregator is the ultimate debugging tool that works as a VarDumper server, Xhprof profiler, local SMTP server, local Sentry, and much more.

    Check out Pavel Buchnev’s post on Profiling PHP (Laravel)Applications with xhprof.

    And for some inspo, see Buggregator for local WordPress development configs.

  • php-soap – A drop-in pure PHP replacement for the ext-soap extension.
  • davecheney/httpstat – A neat visualization tool for HTTP requests. #notphp
  • php-static-analysis/attributes – This package allows using Attributes instead of PHPDoc annotations for static analysis with PHPStan.

    And if you’re new to attributes, check out this guide to PHP attributes by Ashley Allen.

  • rectorphp/type-perfect – Next level type declaration check PHPStan rules.
  • phpstan/phpstan-doctrine – Doctrine extensions for PHPStan.
    If you’re hesitant to use it, check out this thread about possible problems with types returned from database:
  • koriym/spaceman – Give namespace to un-namespaced legacy PHP code.
  • olinox14/path-php – Object-oriented file and path operations, inspired by the path.py python library.
  • cognesy/instructor-php – Structured data outputs with LLMs, in PHP. Designed for simplicity, transparency, and control.
  • NumPower/numpower – A PHP extension for efficient scientific computing and array manipulation with GPU support.

    Check this simple neural net build in PHP from scratch using NumPower.

  • krakjoe/parallel – A succinct parallel concurrency API for PHP. This extension has been updated recently and is now compatible with PHP 8.2 and 8.3.

    Curious about use cases? Check out this example: Processing One Billion Rows in PHP.

  • Swoole v6.0.0-alpha – This alpha release showcases significant changes coming to Swoole, such as multi-threading mode, and support for io_uring for file operations.
  • seanmorris/php-wasm – PHP in Browser, powered by WebAssembly. The maintainer is now supported by WordPress, so it has received quite a few interesting updates recently, such as loading extensions dynamically.

    Version v0.0.9 also includes php-cgi-wasm, which executes the php-cgi SAPI and behaves more like the PHP that runs under Apache, and less like the PHP you invoke on the CLI. This allows you to run almost any PHP application completely client-side.

Symfony

Laravel

Other Frameworks

Misc

Conferences

These PHP events are all worth a visit, and some are still accepting presentation proposals:

Community

  • PHP has the nicest community!

If you have any interesting or useful links to share via PHP Annotated, please leave a comment on this post or let us know on X (formerly Twitter).

Subscribe to PHP Annotated

Roman Pronskiy

Developer Advocate at @PhpStorm, Operations Manager at @The PHP Foundation.

Twitter | GitHub

image description