PHP 8 performance 🐘🐘🐘🐘🐘🐘🐘🐘🚀

dakujem

Andrej Rypo

Posted on November 25, 2020

PHP 8 performance 🐘🐘🐘🐘🐘🐘🐘🐘🚀

Is anyone else seeing a big performance boost on PHP 8?

A couple of tests in my small library dealing with reflection and a bit of regexps are running 30-50% faster 💪!
It is great, but the isolated unit tests are by no means representative.

Has anyone successfully benchmarked a more complex solution already?

As the third party library support for the new PHP version is far from sufficient, I was not yet able to run more complex tests.

This is the hobby lib that's seeing the boost.

GitHub logo dakujem / wire-genie

Autowiring Tool & Dependency Provider.

Wire Genie 🧞

Tests Coverage Status

Autowiring Tool & Dependency Provider for PSR-11 service containers Wire with genie powers.

💿 composer require dakujem/wire-genie

📒 Changelog

What?

A superpowered call_user_func? Yup! And more.

Wire Genie uses your PSR-11 service container to "magically" provide arguments (dependencies).

Allows you to:

  • invoke any callables
  • construct any objects

... with high level of control over the arguments. 💪

Usage

$container = new Any\Psr11\Container([
    Thing::class => new Thing()
    MyService::class => new MyService(),
]);

$callable = function (MyService $service, Thing $thing){ ... };

class Something {
    public function __construct(MyService $service, Thing $thing) { ... }
}

$g = new Dakujem\Wire\Genie($container);

// Magic! The dependencies are resolved from the container.
$value  = $g
Enter fullscreen mode Exit fullscreen mode

And since the attributes can now be used instead of doc-comment annotation parsing (which requires regexp parsing most of the time), the upcoming version will be much faster by design.

💖 💪 🙅 🚩
dakujem
Andrej Rypo

Posted on November 25, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related