PHP Annotated – January 2023

Greetings everyone!

Welcome to the January installment of PHP Annotated, where we’ll catch up on the most exciting things that have happened in the PHP world over the last month, including curated news, articles, tools, and videos.

News

PHP 8.0.27, PHP 8.1.14, PHP 8.2.1 have been released
⚠️️ These are security fix releases.

What’s Next in PhpStorm: The 2023.1 Public Roadmap
In the first release of 2023, we aim to improve performance and bring faster indexing, add 3v4l integration, improve support for generics, as well as PHPStan and Psalm tags, add support for multi-composer and multi-vendor projects, and more.

PHP as WebAssembly and WASI modules
Folks from VMware OCTO WasmLabs are working on porting PHP to WebAssembly using WASI. The concept is not new, you could compile PHP to WebAssembly using emscripten a long time ago.

But now it has become even easier because there are ready-to-use compiled PHP Wasm modules on GitHub: PHP 8.1, PHP 8.2.

Here are a few interesting use cases:

WebAssembly and Sockets: PHP development server on WasmEdge
Docker without containers using WebAssembly. Imagine small containers (e.g. 5MB for a PHP server) that run everywhere with no cold start delay.

By the way, check out WordPress playground, which is a WP running in a browser powered by WebAssembly.

Folks from VMware prepared patches for PHP and say they are very interested in bringing to PHP the benefits WebAssembly provides around application security and delivery, similar to how Python and Ruby are doing.

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 mention it briefly:

RFC: Dynamic class constant fetch
PHP 8.3 will introduce a syntax for looking up class constants:

class Foo {
const BAR = ‚bar‘;
}
$bar = ‚BAR‘;

// New syntax in PHP 8.3:
echo Foo::{$bar};

RFC: More Appropriate Date/Time Exceptions
As of PHP 8.3, when using Date/Time classes, PHP will throw more specific exceptions if something goes wrong.

The procedural style of date/time functions is not affected, and will continue to use warnings and errors as it currently does.

? RFC: Asymmetric Visibility
Ilija Tovilo and Larry Garfield proposed adding Swift-like syntax to allow properties to have separate (“asymmetric”) visibility for read and write operations.

class Foo {
public private(set) string $bar;
}

Voting is currently taking place slowly, and the feature is not receiving enough votes to reach the 2/3 threshold.

? RFC: Add SameSite cookie attribute parameter #PHP 8.3
George Peter Banyard proposes to add a SameSite parameter to all relevant functions.

A set of 18 functions/changes to improve PHP core
Thomas Hruska implemented cubiclesoft/php-ext-qolfuncs – a set of quality-of-life improvement functions designed for PHP core.

The set has some pretty neat additions: str_splice(), str_realloc(), fread_mem(), is_reference(), refcount(), just to name a few. Looking forward to seeing a formal RFC.

Tools

amphp/amp 3.0.0 – The non-blocking concurrency framework for PHP applications has received a major update. It is now based on coroutines using Fibers instead of Generators and it uses revoltphp/event-loop.

Updates have also been made to numerous Amphp ecosystem packages; here are just a few examples: amphp/pipeline and amphp/process.

PHP-DI 7.0 – This update for this dependency injection container package comes with PHP 8.0+ support, @Inject PHPDoc annotation replaced by #[Inject] attribute, PSR-11 2.0 compatibility, and other improvements.

php-ffi/var-dumper – A wrapper for symfony/var-dumper that allows dumping FFI types using the functions dd()` and `dump().

olvlvl/composer-attribute-collector – A convenient and near zero-cost way to retrieve targets of PHP 8 attributes.

PHPCSStandards/PHPCSExtra – A collection of extra rules for use with PHP_CodeSniffer.

cerbero90/enum – A PHP package to supercharge enum functionalities. Basically, it’s a trait you can add to your enums to give them a ton of useful functions.

NoiseByNorthwest/php-spx – A simple & straight-to-the-point PHP profiling extension with its built-in web UI.

PXP – A superset of PHP with extended syntax and runtime capabilities.

Ryan Chandler started off by developing a PHP parser in Rust. The project grew to the whole idea of a superset language.

There were a few attempts to build such a superset for PHP previously (marcioAlmada/yay or nunomaduro/plus-1), but this one looks quite promising.

Apparently, there is another similar attempt, also developed in Rust:
Ara Programming Language – a statically typed programming language that compiles directly to PHP.

Symfony

POC of Clean Architecture with Symfony by Stefano Alletti.

How To Build Activity Log Using Doctrine Events by Jarosław Szutkowski.
Replacing manual API endpoints with API Platform 3 in a Symfony application by Loïc Vernet.

Laravel

How to improve initial page load time by deferring rendering Livewire components by Freek Van der Herten.

Standard API Responses With Laravel Responsables by Wendell Adriel.

Laravel 11: release date and new features by Benjamin Crozat.
Configuring Laravel Pint by Steve (King) McDougall.

Automatic Docblock Generation on Facades by Paul Redmond.

JhumanJ/OpnForm – Simple and open-source form builder.

Laravel Testing Video Course by Povilas Korop (Laravel Daily).

Misc

Funny: I found a new trick to write valid #PHP code with only 6 characters (.,^’)
?
Yes, it’s totally useless… that’s why it’s “funny” ?https://t.co/BD66W8TCMK

— Benoit Viguier (@b_viguier) January 4, 2023

What is the minimum number of characters needed to run every possible program in Php?

In the article, Benoit Viguier explains how you can actually create any PHP script with just these six characters: (.,^‘).

He created a tool to automate the magic b-viguier/PhpFk.

And here is what “hello world” created with PhpFk looks like:

full gist

PHP in 2023 by Brent.

My PHP enum style guide by Brent .

PHP version stats: January, 2023 by Brent Roose.

A regular overview of the PHP versions used, based on the data that clients send to packagist.org (e.g., when they run a composer update command).

PHP 8.* is used by 59.7% of clients, and PHP 7.* takes a 39.1% share. It’s a nice growth for PHP 8 compared to last year, when it was 45.1% and 53.4% respectively.

2.6 Million Domains and ~45,000 Exposed Phpinfo() by sdcat.
The author scanned 2.6 domains for scripts like info.php or phpinfo.php and found 45,000 of them.

In the article, you can learn why it can be dangerous to expose phpinfo().

From open redirect to RCE in one week by Anton Hrytskevich.

Keep Cognitive Complexity Low with PHPStan by Tomas Votruba.

How to release PHP 8.1 and 7.2 package in the Same Repository by Tomas Votruba.

PHP Performance in 2022: A Year in Review by Benjamin Eberlei – Benjamin shares a few lesser-known performance improvements in PHP 8.2.

For instance, in PHP 8.2 list arrays are significantly more memory-efficient thanks to Dmitry Stogov.

A test script that creates an array list of 100k integers shows reduced memory usage from 4,3 MB to 2,3 MB.

php-pds/composer-script-name – A new standard for naming composer scripts available for public review.

Paul M. Jones did a thorough research and suggests a few script names to be used across the PHP ecosystem: test, test-coverage, test-*, cs-fix, analyze, check.

Compose a Developer Environment easily for PHP with Nix by Soner Sayakci.

Video

? Solving an Array Reduce Interview Question – in PHP by Matt Stauffer.

? Xdebug 3: Skipping Files when Debugging by Derick Rethans.

? Xdebug 3.2: Return Value Debugging with PhpStorm – Derrick Rethans shows off a new feature available with PhpStorm 2022.3.

? Upgrading to PHP 8.2 by Brent.

Top 30 YouTube Channels for Laravel and PHP by Ashley Allen.

On php.net Events: February 2023 you can find the next PHP meetup near you

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

Subscribe
to PHP Annotated

Roman Pronskiy

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

Twitter | GitHub

The PhpStorm Blog : The Lightning-Smart IDE for PHP Programming | The JetBrains Blog

Read More

Latest News

PHP-Releases

PHP 8.3.4 released!

PHP 8.2.17 released!

PHP 8.1.27 released!

Generated by Feedzy