Object properties and immutability – larry@garfieldtech.com

Object properties and immutability

There has been much discussion in recent weeks in PHP circles about how to make objects more immutable. There have been a number of proposals made either formally or informally that relate to object property access, all aimed at making objects safer through restricting write access in some way.

Since my last mega post on PHP object ergonomics was so well-received and successful (it resulted in both constructor promotion and named arguments being added to PHP 8.0, thanks Nikita!), I figure I’ll offer another summary of the problem space in the hopes of a deeper analysis suggesting a unified way forward.

Continue reading on PeakD

28 December 2020 – 5:30pm

Xdebug Update: November 2020 – Derick Rethans

Xdebug Update: November 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, especially now some companies have dropped out, and that GitHub sponsors is no longer matching supporters.

You can become a patron or support me through GitHub Sponsors. I am currently 73% 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 November, I worked on Xdebug for about 72 hours, with funding being around 30 hours. I worked mostly on the following things:

Xdebug 3

The biggest thing this month is the release of Xdebug 3!

After about a year and a half after starting with this massive undertaking, it is finally ready. I released it the day before PHP 8 came out. Of course Xdebug 3 also supports PHP 8. It however drops support for PHP 7.1 as per the support policy.

As is custom with a x.0.0 release, a few bugs did occur. I am currently working at addressing then. I plan to release bug release versions weekly throughout December, as long as it makes sense to do so.

Xdebug 3 should be a lot faster, as it is a lot more clever on when it hooks into things it needs to do. That does come with changes as to how Xdebug needs to be configured. Xdebug 3’s upgrade guide lists all the changes.

The https://xdebug.org web site now only contains Xdebug 3 documentation, with the old site archived at https://2.xdebug.org until the end of 2021.

I will be recording some videos about the ideas behind the changes, and how to use Xdebug 3. I am also playing with the idea of hosting “Office Hours” for an hour a week where users can drop-in with questions and problems. If that is something that you’re interested in, please let me know.

Xdebug Cloud

I have been continuing to test Xdebug Cloud, and I am working with a few private alpha testers. They’re putting the hosted Cloud service to its paces with the latest PhpStorm 2020.3 release candidate. As I suspected, the alpha testers found some minor issues which I will be addressing during December.

The web site for Xdebug Cloud does not have a design yet, but this is coming this month as well.

If you want to be kept up to date with Xdebug Cloud, please sign up to the mailinglist, which I will use to send out an update not more than once a month.

Business Supporter Scheme and Funding

In November, two new supporters signed up.

Thank you Find My Electric and Edmonds Commerce!

If you, or your company, would also like to support Xdebug, head over to the support page!

Besides business support, I also maintain a Patreon page and a profile on GitHub sponsors.

Development-Mode Modules for Mezzio – Matthew Weier O’Phinney

I fielded a question in the Laminas Slack yesterday that I realized should likely be a blog post.
The question was:

Is there a way to register development-mode-only modules in Mezzio?

There’s actually multiple ways to do it, though one that is probably more preferable to others.

Conditional ConfigProviders

We already provide one pattern for doing this in the Mezzio skeleton application, by conditionally including the mezzio-swoole ConfigProvider if the class is present:

class_exists(\Some\ConfigProvider::class) ? \Some\ConfigProvider::class : function (): array { return []; },

Alternately, you could express this as an anonymous function:

function (): array { if (class_exists(\Some\ConfigProvider::class)) { return (new \Some\ConfigProvider())(); } return [];

(The values provided to the ConfigAggregator constructor can be either string class names of config providers, or functions returning arrays, which is why either of these will work.)

This approach is primarily useful if the config provider will only be installed as a require-dev dependency.
But what if you are defining the config provider in your own code, and it’s always present?

Development-Mode Configuration Aggregation

Another possibility is to do some “hacking” around how laminas-development-mode works with Mezzio.
laminas-development-mode in Mezzio works with the config/autoload/development.local.php.dist file; enabling development mode symlinks config/autoload/development.local.php to that file.
That file just needs to return an array.
As such, you could totally write it to aggregate other config providers, as well as some default development configuration, using the same tools you do in your primary configuration file:

// in config/autoload/development.local.php.dist: declare(strict_types=1); use Laminas\ConfigAggregator\ArrayProvider;
use Laminas\ConfigAggregator\ConfigAggregator; $developmentConfig = [ // app-level development config you want to define
]; $aggregator = new ConfigAggregator([ // any ConfigProviders you want to list, then: new ArrayProvider($developmentConfig),
]); return $aggregator->getMergedConfig();

This approach is likely the best to use, as it makes it more clear in your main config what the default modules are, and any dev-only ones are now listed in this file.

mwop Development-Mode Modules for Mezzio was originally published on https://mwop.net by .