PHP Annotated – June 2023

PHP Annotated Monthly

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

Highlights

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: 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 {
            // Override the "read" action with arbitrary logic.
            get => $this->first . " " . $this->last;
     
            // Override the "write" action with arbitrary logic.
            set($value) => [$this->first, $this->last] = explode(' ', $value);
        }
    
  • 📣 RFC: Marking overridden methods (#[\Override])
    Tim Düsterhus suggests introducing a new #[\Override] attribute. This attribute, when applied to a method, would prompt the engine to verify the existence of a method with the same name in a parent class or any implemented interfaces.

    interface I {    public function i(): void;
    }
     
    class P {
        #[\Override]
        public function i(): void {} // Fatal error: P::i() has #[\Override] attribute, but no matching parent method exists
    }
     
    class C extends P implements I {} // All good 👍
    
  • 📣RFC: NameOf
    Robert Landers proposes adding a global nameof() function. This function would enable developers to swiftly and easily retrieve the name of virtually any user-defined variable, property, constant, or member.

    echo nameof($variable); // variable 
    echo nameof($object->property); // property
    echo nameof(Enum::Case); // Case
    echo nameof(Object::Const); // Const
    echo nameof(myFunction(...)); // myFunction
    echo nameof(MY_CONSTANT); // MY_CONSTANT
    

Tools

  • wp-now – A local dev environment from the WordPress engineering team.
    This tool leverages WebAssembly to operate PHP on top of Node.js’ webserver. It’s faster than Docker-based environments and can be used with any PHP apps, although, you’ll have to figure out a way to run your DB.
  • PHP Monitor 6.0 now available – This major update introduces the new PHP Version Manager, a new Standalone Mode that allows the app to work without having Valet installed, and more.
  • pmjones/AutoShel – Automatically maps CLI command names to PHP command classes in a specified namespace, reflecting on a specified main method within that class to determine the argument and option values. The method parameters may be scalar values(int, float, string, bool) or arrays.
  • jolicode/castor – A task runner and command launcher designed with a focus on developer experience, built using PHP.
  • ProjektGopher/whisky – Simple and framework-agnostic CLI tool for managing and enforcing a PHP project’s git hooks across a team.
  • schranz-search/schranz-search – Search abstraction over different search engines written in PHP. The currently implemented engines include Elasticsearch, Opensearch, Algolia, Meilisearch, RediSearch, Solr, and Typesense.
  • TestGenAI – A tool by Tomas Votruba, the author of Rector, to generate unit tests for PHP code.
  • librarianphp/librarian – A static site generator and markdown indexer inspired by Hugo and DEV, written in PHP. Read the story behind this creation.

Symfony

Laravel

Other frameworks

Misc

Conferences

In-person events are in full swing. Check out these upcoming PHP gigs worth visiting and applying to present at:

  • Laracon US – Nashville, TN, USA, July 19–20, 2023.
  • CakeFest – Los Angeles, CA, USA, Sep 28–Oct 3, 2023.
  • Longhorn PHP – Austin, TX, USA, November 2-4, 2023.
  • SymfonyCon – Brussels, Belgium, December 7–8, 2023.

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


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

Product marketing manager for @PhpStorm, had a hand in the creation of @The PHP Foundation.

Twitter | GitHub

image description