← Back to context

Comment by kugelblitz

2 years ago

Yeah, some things are still a mess, but many things I use constantly have improved so much. Here is an excerpt of a function that shows many of the updates that I use regularly:

  #[AsMessageHandler]
  readonly class JobEditedHandler
  {
      public function __construct(
          private Environment $twig,
          private EmailService $mailer,
          private string $vatRate,
      ) {}

      public function __invoke(JobEdited $jobEdited): void
      {
          $this->sendNotificationToJobPublisher($jobEdited);
      }

You have attributes, much better type-hinting, constructor property promotion, read-only properties / classes. Additionally you have native Enums, named arguments and also smaller things such as match expressions (instead of case switch), array spread operator, null coalescing assignment operator, etc, etc.

Especially in a CRUD-heavy setting like mine (I run a niche jobboard) it reduces so much boilerplate and increases type-safety, thus makes it way less error-prone. Combined with new static analyzers (phpstan, php-cs-fixer, psalm - take your pick), you find possible errors way earlier now.

I think it gets a lot of inspiration from Java. Symfony gets lots of inspiration from Spring Boot. The Twig templating language is heavily related to the Django templating language. So many of the tools and concepts are somewhat battle-tested.

And this is on top of the huge performance improvements in the last years.

So yeah, there's many things that are still fixable. But the improvements have been staggering.