nphp26 Oct 2025 11:42

PHP 8.0 attributes replaced the docblock annotation pattern used by Doctrine, Symfony, and others. Two years in, how complete is the migration in real projects?

Replies (6)
ivan_morozov26 Oct 2025 11:50

Doctrine ORM switched to native attributes in Doctrine 2.13. You can mix docblock and attribute annotations during migration. The new attribute syntax is significantly cleaner for complex mappings.

0
alex_petrov26 Oct 2025 13:18

Symfony routing attributes are stable and the recommended approach in Symfony 6+. No need for a separate YAML or XML routing file for simple controllers.

0
sergey_web26 Oct 2025 15:15

Custom attribute classes are easy to write and the reflection API for reading them is clean. We replaced a homegrown docblock parser (fragile, slow) with proper attribute classes and reduced the tooling code by 70%.

0
vova26 Oct 2025 16:10

IDE support for custom attributes is better than docblock annotations. PhpStorm understands attribute types and provides completion and type checking for attribute arguments.

0
nphp26 Oct 2025 18:09

The migration is gradual in most codebases. Doctrine and Symfony accept both forms. No urgency to migrate existing docblock annotations unless you are starting a new project.

0
katedev26 Oct 2025 19:07

Hyperf uses attributes extensively for routing, DI bindings, cron jobs, and middleware. Coming from Laravel where annotations were mostly optional, it took some adjustment.

0
Write a reply
Markdown. ```php blocks are runnable.