News

PHP Annotated – January 2025

PHP Annotated

Welcome to the January edition of PHP Annotated! This recap is carefully handcrafted and brings you the most interesting developments in the PHP community over the past couple of months, so you don’t have to sift through the noise, we’ve done it for you.

Highlights

PHP Core

  • RFC: Add persistent curl share handles

    PHP 8.5 will bring a new function curl_share_init_persistent(), which would allow cURL handles to be stored in global memory and reused in subsequent requests.

    Persistence allows PHP scripts to eliminate the overhead of establishing a connection (and DNS lookups, SSL session IDs, etc.) and can improve performance and reliability.

  • RFC: Support Closures in constant expressions

    In PHP 8.5 it will be possible to use closures in previously

    • In attribute parameters,
    • As default values of properties and parameters.
    • Constants and class constants.
    <?php
    
    class Foo
    {
        public static Closure $callback = static function ($item) { echo "Hello world"; };
    }
    
    
    function my_array_filter(
        array $array,
        Closure $callback = static function ($item) { return !empty($item); },
    ) {
        // ...
    }
    
  • RFC: Attributes on Constants

    Attributes were first introduced in the RFC: Attributes v2. Daniel Scherzer proposes to add support for attributes on compile-time non-class constants.

    #[\MyAttribute]
    const EXAMPLE = 1;
    
  • RFC: Error Backtraces v2

    Previously, unlike exceptions, PHP errors did not provide backtraces, which made it difficult to figure out their underlying cause. PHP 8.5 will come with a new ini setting fatal_error_backtraces=1 which will generate detailed error messages and trace for E_ERRORs.

  • 📣 RFC: Records vs. RFC: Data Class vs. RFC: Structs

    Apparently, there is a big interest in the community to add a simple native way of creating Value Objects in PHP.

    Which one would you prefer?

Tools

AI

PhpStorm

  • PhpStorm 2024.3 is now available

    The new PhpStorm comes with full PHP 8.4 support, inline AI prompts, Laravel Herd support.

    Support for .env files is now built into PhpStorm. Previously it required installing a separate plugin.

    JetBrains also announced a closed beta for Junie, AI Coding Agent for IDEs.

  • MetaStorm – This plugin allows extending PhpStorm’s behaviour and adding support for your custom frameworks with a few lines in a config file. It unlocks both references and autocompletion at regular places such as method($object,), render(), etc.
  • buggregator/phpstorm-plugin – This plugin works in the pair with buggregator/trap and allows dumping and debugging PHP projects just inside the IDE. Supports VarDumper server, Xhprof profiler, local SMTP server, local Sentry, and much more.
  • Cron & Crontab Support Plugin

Frameworks

Misc

Conferences

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

To find a PHP meetup happening near you, check out the calendar on php.net.

Fun


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/Twitter.

Subscribe to PHP Annotated

Roman Pronskiy

Developer Advocate at @PhpStorm, Executive Director at @The PHP Foundation.

Twitter | GitHub

image description