PHP: attributes vs annotations. Optimising Doctrine metadata

  • XML driver
  • YAML driver
  • Static PHP driver
  • PHP driver
  • Annotations driver
  • Attributes driver
Example usage of attributes
How each option looks: AnnotationDriver, AttributeDriver, StaticPHPDriver, PHPDriver
Script for generating code
  • Is it worth using attributes instead of annotations everywhere possible in whole new projects? Definitely.
  • Should you refactor annotations into attributes in your legacy application? It depends on non functional requirements (e.g. if you have the goal to optimise the project).
    Code generation can be helpful: we use a similar script in our production environment (also you may want to try rector).

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store