PHP 8.0 feature focus: quality of life improvements –

Our last article looked at a new way to make null values nicer to work with. PHP 8.0 has a lot of such features that make everyday coding more fun, but there are too many of them to give them all their own articles. So today we’ll cover a grab bag of changes and improvements that aren’t web-shattering but should make working with PHP overall more pleasant.
New string functions PHP has a huge array of string functions (sorry, too easy), from the very useful to the rather obscure.

PHP 8.0 feature focus: nullsafe methods –

Last week we used Weak Maps to solve one edge case. Today, we simplify the most common and annoying edge case: That of nothingness.
Let’s be honest, null values suck. They’ve been called the billion dollar mistake, but programmers in most languages still have to deal with it. (Except for those working in Rust.) They especially suck when you have a variable that could be an object or null. If it’s an object, presumably you know it’s type and what it can do; if it’s null, you can’t do much of anything with it.

Step-debugging linked composer dependencies with PhpStorm – Rob Allen

One project I’m working on has multiple separate parts in different git repositories that are brought into the main project using linked composer directories. I needed to get step debugging working in PhpStorm and this is the approach I took.

Directory layout

My project is laid out on disk like this:

├── main-app/
│   ├── public/
│   ├── src/
│   ├── tests/
│   ├── vendor/
│   └── composer.json
└── plugin-one/    ├── src/    └── tests/

As you can see I have main-app and plugin-one which are the two sets of source code that I need to work on.

Linked directories in composer

We need to set up ./plugin-one/ as a composer dependency of ./main-app/ such that it appears under ./main-app/vendor/client/plugin-one/, but set-up so that we can edit the original files and have main-app pick up the changes.

This is done by setting up a repository in our composer.json that points to the relevant path using a symlink. These are know as Path repositories and look like this in ./main-app/composer.json:

"repositories": [ { "type": "path", "url": "../plugin-one" "options": { "symlink": true } }, ]

I can then set my require like this:

"require": { "client/plugin-one": "@dev", },

The net result is that ./main-app/vendor/client/plugin-one is a symlink to ./plugin-one

Setting up PhpStorm

We create a PhpStorm project for ./main-app and then add plug-one to it as a “content root”:

  • Go to Preferences -> Directories
  • Click “+ Add Content Root” add add {full path}/plugin-one
  • Click “Apply” and then “OK” to close the Preferences dialog

We now have the same source code in the project twice (once in ./plugin-one and once in ./main-app/vendor/client/plugin-one), so we need to excluded the vendor directory:

  • In the Project tree view, find the main-app/vendor/client/plugin-one folder and select it
  • Right click -> Mark Directory As -> Excluded

The folder will now be coloured orange, so we know it’s excluded.

Set-up for debugging

PhpStorm now knows about our source code, so next we need to map it to the server. I’m using Docker for this project, but it’s the for any remote-like project.

  • Go to Preferences -> Languages & Frameworks -> PHP -> Servers
  • Add a new entry:
    • Name: {dev-hostname-for-main-app}
    • Host: {dev-hostname-for-main-app}
    • Port: 8888 (or whatever)
    • Debugger: Xdebug (of course!)
    • [✓] Use path mappings
    • In the File/Directory list set up these mappings:
      • {full path on local disk}/main-app => /var/www/html/main-app
      • {full path on local disk}/plugin-one => /var/www/html/plugin-one

The key bit for this article is that path mapping section. The "/var/www/html" is whatever the correct path is on your Docker/Vagrant/whatever host.

Finally, click the menu item Run -> Start Listening for PHP Debug Connections. Note that if this is already selected, then the menu item does not exist and the menu item Stop Listening for PHP Debug Connections is in its place.

Start debugging

You can now set breakpoints in plugin-one/src/whatever.php and PhpStorm will stop on them.

If you are debugging a website using a browser then get the relevant Xdebug extension for Chrome or Firefox.

If it’s an API, then you’ll need to set a cookie to enable Xdebug for the request:

curl --cookie 'XDEBUG_SESSION=PHPSTORM; path=/' "http://{dev-hostname-for-main-app}:8888/foo/bar"

Translate to your API client of choice!


This worked for me, hopefully it’ll work for you too if you have a similar situation!

Xdebug Update: September 2020 – Derick Rethans

Xdebug Update: September 2020

Another monthly update where I explain what happened with Xdebug development in this past month. These will be published on the first Tuesday after the 5th of each month.

Patreon and GitHub supporters will get it earlier, on the first of each month.

I am currently looking for more funding.

You can become a patron or support me through GitHub Sponsors I am currently 59% towards my $1,000 per month goal.

If you are leading a team or company, then it is also possible to support Xdebug through a subscription.

In September, I worked on Xdebug for about 60 hours, with funding being around 70 hours. I worked mostly on the following things:

Xdebug 3

This month I mostly focussed on getting Xdebug 3 in shape for a first beta release, with all the new configuration names in place. There are now only a few tasks before I can release Xdebug 3.0.0beta1. I plan to release this around PHP 8.0RC2.

The main changes that I made was to rename the following four configuration settings, mostly to get “rid” of the remote naming:

  • xdebug.remote_hostxdebug.client_host

  • xdebug.remote_portxdebug.client_port

  • xdebug.remote_connect_backxdebug.discover_client_host

  • xdebug.remote_addr_headerxdebug.client_discovery_header

I hope that these new names are easier to explain, and of course the upgrade guide explains the changes too.


There were two Xdebug releases in September. 2.9.7 changes the step debugger to set up TCP Keepalive probes. This results in better time-out management in case network connections between Xdebug and an IDE drops.

Unfortunately this patch caused compilation issues on FreeBSD where some OS specific flags are different (but the same as OSX, which Xdebug did handle correctly). A fix for this, as well as a fix for path/branch coverage with foreach loops resulted in the 2.9.8 release. I expect to create one more release related to the TCP Keepalive addition as the current release still does not compile for AIX.

Beyond this, I do not expect any more release of the Xdebug 2.9 series unless security or crash bugs are present.

Truncated by Planet PHP, read more at the original (another 1282 bytes)

PHP 8.0 feature focus: Weak maps –

In our last episode, we discussed PHP 8’s new match() expression. Today we look at an edge case feature that will save your edge case.
PHP 7.4 introduced the concept of Weak References, which allow an object to be referenced without incrementing its reference counter. That’s a bit obscure and in practice not all that useful in most cases. What we were really waiting for is Weak Maps, which have landed in PHP 8.