PHP Annotated – July 2023
Welcome to the July edition of PHP Annotated! We’ll recap the most interesting developments in the PHP community over the past month, featuring handpicked news, articles, tools, and videos.
Highlights
- PHP 8.3.0 beta 1 released
With the first beta release, the active development phase has ended, meaning that the list of new features and changes in the 8.3 branch can be considered final.If you are on Mac, check out Nuno Maduro’s how-to-install PHP 8.3 instructions. Otherwise, Docker images are probably the best option to try it without any hassle.
Thanks to Thomas Jarrand, php.net now has an endpoint to get the current state of all PHP branches: php.net/releases/states.
- PHP 9 logo
The author of elePHPant design and PHP 8 logo author, Vincent Pontier, came up with the idea for the PHP 9 logo:
- PHP Version Stats – July, 2023
A regular overview of the PHP versions used, based on the data that clients send to packagist.org (e.g. when they run acomposer update
command). 68.8% of clients use PHP 8.*, and PHP 7.* accounts for 29.7%. Slow but nice growth for PHP 8 compared to last year, when it was 59.7%.According to Remi Repository stats, which probably represents a slightly different segment of users, 35% of users use PHP 8.* and 63% use PHP 7.*.
PHP download numbers for 2 weeks:
– 8.2: 9%
– 8.1: 16%
– 8.0: 10%
– 7.4: 27%
– 7.3: 8%
– 7.2: 12%
– 7.1: 15%
– 7.0: 1%
– 5.6: 3%So 2/3 for EOL versions pic.twitter.com/QwZvO9e3zC
— RemiRepository (@RemiRepository) June 20, 2023
By the way, WordPress is dropping PHP 5 support in the next WordPress 6.3 release. Currently, 5.5% of WordPress installations still use PHP 5.
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: Interface Default Methods
This RFC by Levi Morisson has stirred up a lot of discussion.Levi proposed that interfaces could have implementations for methods, similar to what is possible with Kotlin, Swift (extend protocols), Java, C#, and other languages.
If you feel that multiple inheritance is wrong and interfaces should never have an implementation, Larry Garfield suggests giving it a second thought before rejecting a weird idea.
Brent also talks about this in his What is a Best Practice? video and elaborates even deeper in his “Is A” or “Acts As” post.
As George mentioned, some might have voted against the proposal because it’s a drastic change brought up too close to the feature freeze of PHP 8.3.
- ✅ RFC: Marking overridden methods (#[\Override])
PHP 8.3 will have a new attribute,#[\Override]
. When applied to a method, it will prompt the engine to verify the existence of a method with the same name in a parent class or any implemented interfaces.It is similar to what other languages have, such as Java, Kotlin, Swift, and C#.
- ✅ RFC: Path to Saner Increment/Decrement operators
The behavior of the++
and--
operators will be more consistent in PHP 8.3
If you want a real showcase of the problem, check out this example:#PHP is always good for some excitement during the day. What do you expect the following code to print?$value = ‘5d9’;$value++;$value++;$value++;
var_dump($value);— alcaeus (@alcaeus) June 29, 2023
- ✅ RFC: PDO driver specific subclasses
Currently, PHP has a single PDO class for all databases. However, depending on the actual DB driver extensions you have in your installation, this class can have a different set of methods.The RFC by Dan Ack suggests adding a set of specific subclasses with a separate class for each supported database.
- ✅ PR: Add fallback value syntax for ini variables
A neat addition by Gabriel Fontes is coming in PHP 8.3! It will be possible to use default values in thephp.ini
settings in addition to environment variables:xdebug.start_with_request = ${PHP_XDEBUG_START_WITH_REQUEST:-default}
- dunglas/php-dev-docker – Docker image to hack the PHP interpreter.
Kévin Dunglas prepared a Docker image specifically for debugging and developing the PHP interpreter. Is a PHP script causing a segfault? Do you want to develop a PHP extension? This image is for you! It contains all the tools you’ll need.
Tools
- NativePHP – Develop desktop applications with PHP
The tool by Marcel Pociot provides simple APIs and tooling to build cross-platform desktop apps just like you would when building your usual web apps.Behind the scenes, it uses either Electron or Tauri, so ‘Native’ in the name might be a bit misleading. But from the perspective of a PHP developer, it is all nicely wrapped in familiar tooling and syntax. Marcel covered how it works in the announcement.
So far, it only works with Laravel, but folks promise to implement adapters for other frameworks and native PHP.
Here is an example of an app built with NativePHP – simonhamp/cronikl – A simple tool to manage cron jobs.
- Laravel Herd – One-click PHP development environment.
Another tool by Marcel Pociot and Beyond Code. It’s a local dev environment for PHP on macOS that does not require you to deal with homebrew or anything else at all, as it ships everything pre-built.I’m still a big fan of IndigoStack, which also provides a local env but with more flexibility.
- aschmelyun/diode – A WASM-powered local development environment for Laravel and another approach to a local dev environment inspired by wp-now. This video offers a behind-the-scenes look.
- yzen-dev/plain-to-class – This hydrator transforms your data into a typed object. It does not require inheritance, does not depend on any framework, and, according to benchmarks, is one of the most effective.
- cerbero90/json-parser – A zero-dependencies parser to read large JSON from any source in a memory-efficient way.
- alexandre-daubois/lazy-stream – Write and read data to and from streams only when it is needed.
- NumPower – This C extension for PHP was created to provide the foundation for efficient scientific computing in PHP, and leverage the machine learning tools and libraries that already exist and can benefit from it.
Symfony
- Romaixn/gosumer – Consuming your Symfony Messenger messages with Go. Check out the introductory post.
- Prepare Yourself for Symfony 6.4 and Symfony 7.0
Laravel
- Laracon Recap – New products announced: Herd, Volt, Folio, Prompts (not related to AI), NativePHP, as well as Pest 2.9 and Livewire v3. All talks are available on the Laravel YouTube channel.
- blinq-dev/laravel-synth – Generate Laravel code with ChatGPT.
- yllw-digital/laravel-chatgpt-mock-api – Generate smart API mocks in Laravel using ChatGPT prompts.
- 8 Bad Habits I See Laravel Developers Make by Code With Dary.
- 📺 Expressing strong opinions on how to structure Laravel apps with Steve, Brent, and Bobby.
- 📺 Laracasts: PhpStorm for Laravel Developers.
Other frameworks
Misc
- Building PHP Extension with Rust for Fun and Profit by Ahmad Rosid.
- Build Your Own Template Engine in PHP – Rendering & Echo by Ryan Chandler.
- 3 Compelling Reasons For Developers To Write Tests by Christoph Rumpel.
- 📺 Composer, Packagist, and Open Source – Interview with Jordi Boggiano.
-
Too much fun with legacy PHP hacks today, time to go home! 😃👋 #php pic.twitter.com/QqFr99rcta
— Christian Lück (@another_clue) June 20, 2023
Fun
-
Do you like mysteries? Here’s one for you, PHP lovers. 🐘 https://t.co/EodRpuYGny pic.twitter.com/4kC9X0WnDz
— Nuno Maduro (@enunomaduro) June 19, 2023
-
If your app has more than 1 php file you have launched too late.
— Jon Yongfook (@yongfook) July 8, 2023
- There is a new elephpant for sale!
Conferences
Check out these upcoming PHP gigs worth visiting and applying to present at:
- PHPKonf – Istanbul, Turkey, September 2, 2023. CFP 🆕
- CakeFest – Los Angeles, CA, USA, September 28–Oct 3, 2023.
- Longhorn PHP – Austin, TX, USA, November 2–4, 2023.
- PHPCon Poland – Zawiercie, Poland, November 17–18, 2023. CFP 🆕
- Laracon AU – Sydney, Australia, November 16–17, 2023.
- SymfonyCon – Brussels, Belgium, December 7–8, 2023. CFP
- PHP UK – London, UK, February 15–16, 2024. CFP 🆕
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.