PHP Annotated – April 2023

Greetings everyone!

Welcome to the April 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.1.18 and PHP 8.2.5 released.
?
These are bug-fix releases.

Pest 2.0 released
Pest v2 brings many new features such as retrying testing, profiling slow tests, support for the new arch plugin, and many more.

? The future of Pest v2 by Nuno Maduro.
? Let’s look at Pest v2 by Laravel News.

Bref 2.0 released
Bref allows you to deploy PHP apps to the AWS Lambda serverless platform with ease.

This major update brings simpler configuration for setting up PHP, revamped Laravel integration, faster deployments, automatic loading of secrets in environment variables at runtime, and a simpler docker-compose.yml for local development.

Subscribe to the Serverless PHP newsletter for more content on the topic.

PER Coding Style 2.0 released
The new version of PHP coding style guidelines fixes some issues as well as updates the guide for recent PHP syntax additions.

To see how PER CS 2.0 differs from PSR-12, click here.

PhpStorm 2023.1 released
This is the first major update to PhpStorm this year. It brings integration with 3v4l.org, improved performance, enhancements to the new UI, a DFA debugger for PHP, and much more.

PHP Foundation Update, March 2023
The PHP Foundation team announced the possibility of supporting PHP via GitHub Sponsors and revealed a new Advisory Board initiative.
PHP 8.3 release managers announced
As is tradition, PHP 8.3 will have 2 rookie release managers: Jakub Zelenka, PHP core developer sponsored by the PHP Foundation, and Eric Mann. They will be assisted by veteran RM Pierrick Charron.

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 list a few highlights:

RFC: Arbitrary static variable initializers
PHP allows declaring static variables inside any functions. Their values outlive the function call and are shared across future execution of the function.

In PHP 8.3, you can assign them any expression, e.g. the result of another function.

function bar() {
echo „bar() calledn“;
return 1;
}

function foo() {
static $i = bar(); // This currently produces a fatal error, but will work in PHP 8.3
echo $i++, „n“;
}

foo();
// bar() called
// 1
foo();
// 2
foo();
// 3

As a side effect, in PHP 8.3 redeclaring static variables will be forbidden. This will fix some PHP quirks that you have hopefully never seen in real code:

<?php
function f()
{
static $x = 1;

return $x;

static $x = 2;
}
echo f();

If you expected the second static declaration to be unreachable, you’d unfortunately be mistaken: https://3v4l.org/HhpYj

? RFC: Clone with
Máté Kocsis proposed to add support for a new language construct called “clone with” by extending the clone operator, making it possible to write “wither” methods for any kind of instance properties (declared/dynamic, typed/untyped, readonly/non-readonly) with less code.

Example
class Response implements ResponseInterface { public readonly int $statusCode;
public readonly string $reasonPhrase;
// …
public function withStatus($code, $reasonPhrase = “): Response
{
return clone $this with {
statusCode: $code,
reasonPhrase: $reasonPhrase
};
}
// …
}

$response = new Response(200);
$response->withStatus(201)->withStatus(202);

? RFC: New core autoloading mechanism with support for function autoloading
George Peter Banyard and Dan Ackroyd propose a better-designed class-autoloading mechanism, and add a new function-autoloading mechanism.

? Jakub Zelenka proposes to form PHP Technical Committee
PHP uses RFC voting to decide on user-visible language changes, which works well despite some known issues. However, it’s not as effective for technical changes that impact PHP internals and extension APIs, and conflicts between contributors on technical bases are not easily resolved.

The proposed committee would consist of 5 elected members and, should a dispute or question about a change arise, the committee may be called on to resolve it.

Tools

crazywhalecc/static-php-cli – The tool for building PHP apps into a single binary file with no extra dependencies.

aschmelyun/subvert – Generate subtitles, summaries, and chapters from videos in seconds.

yiisoft/db – Framework-agnostic query builder for different types of databases (MariaDB, MSSQL, MySQL, Oracle, PostgreSQL, and SQLite).

Crell/EnvMapper – Easily map environment variables into defined classed objects, ready for dependency injection.

PHP Skeleton for Bison by Anton Sukhachev.
The syntax of PHP and many other languages is described by grammar in Bison format. mrsuh/php-bison-skeleton makes it possible to generate a Bison parser in PHP without third-party dependencies.

? NativePHP
Marcel Pociot is building a tool to run Laravel/PHP apps on desktop on top of Electron or Tauri.

I heard you like ? tweets, so here’s some NativePHP hot-reloading for you. pic.twitter.com/ULALsxdsxv

— Marcel Pociot ? (@marcelpociot) April 13, 2023

Symfony

Aggressive Caching with Symfony HTTP Client by Grégoire Pineau.

New in Symfony 6.3 posts by Javier Eguiluz:

Targeted Value Resolvers
Early Hints
NoSuspiciousCharacters Constraint
HTTP Exception Attributes
Mapping Request Data to Typed Objects

Leverage Symfony VarDumper Component to Enhance your Dumps by Grégoire Pineau.

Laravel

Laravel Valet 4.0 released
Despite the name, Laravel Valet is a minimalistic development environment for macOS that can be used for any PHP project.

This release is mostly about rewriting the internals, so they’re easier to debug, fix, and modify. It also brings a new valet status command and supports Expose as a sharing option.

Laravel IDEA 7.0
The popular plugin for PhpStorm has received a major update. It includes the “New Eloquent Model” UI and Twig templates support.

Check out this video demo on Laravel Daily.

Build a ChatGPT clone using the new OpenAI Chat API by Marcel Pociot.

Everything You Can Test In Your Laravel Application by Christoph Rumpel – Excellent guide with examples of scenarios you’ll likely need to test on real applications.
TomasVotruba/bladestan – PHPStan analysis for Blade templates.

lunarphp/lunar – An open-source headless e-commerce package for Laravel. You have complete freedom to create your own storefront, but the backend work is already done for you.

area17/twill – A CMS toolkit for Laravel that helps rapidly create a custom admin console that is intuitive, powerful, and flexible.

? Laravel Weekly Update #6 – The team now provides a weekly roundup of Laravel news and updates in short videos.

Misc

Announcing WCGI: WebAssembly + CGI – Folks from Wasmer present a new technology to reuse existing CGI applications by compiling them to WASI. This allows shipping ultra-small packages that contain only business logic and static assets and no HTTP stack or bulky Docker containers.

Avoiding one-liners in PHP by Andreas Möller. It will make your code easier to understand and debug.

Secure Your PHP Code With Taint Analysis by Qodana by Valerie Kuzmina.

Discovering PHP’s first-class callable syntax by Freek Van der Herten.

Blazingly Fast Markdown Parsing in PHP using FFI and Rust by Ryan Chandler.

Cloning readonly properties in PHP 8.3 by Brent Roose.

Using PSR-3 placeholders properly by Larry Garfield.

Extending PHP 8.1 enums with attributes by Rob Fonseca. A simple but neat usage of attributes.

Community

In case you missed it, Brent and Roman are now doing a video version of PHP Annotated. Check out the latest installment and be sure to subscribe to the PHP Annotated YouTube channel.

PoPHPularity: Is it decreasing and what to do about it? by Christian Olear.

Modern PHP by Dimitrios Lytras – “While I wasn’t paying attention, PHP got quite good.”

Every time a kid flags me down in the Lambo and asks me what I do for work I tell them I code in PHP the greatest programming language of all time ?

That car has done so much PHP evangelism

— Taylor Otwell ? (@taylorotwell) April 14, 2023

Conferences

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

php[tek] – Chicago (US), May 16–18, 2023.

phpday 2023 – Verona (Italy), May 18–19, 2023.

International PHP Conference – Berlin (Germany), May 22–26, 2023.

Laracon US – Nashville (US), July 19–20, 2023.

CakeFest – Los Angeles (US), Sep 28–3, 2023.

SymfonyCon – Brussels (Belgium), December 7–8, 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 creation of @The PHP Foundation.

Twitter | GitHub

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

Read More

Generated by Feedzy