doctrine / DoctrineORMModule

Doctrine ORM Module for Laminas
https://www.doctrine-project.org/projects/doctrine-orm-module.html
MIT License
437 stars 229 forks source link

Support Attributes instead of Annotations #733

Closed boscho87 closed 10 months ago

boscho87 commented 1 year ago

With PHP 8 we have attributes available, it will make sense to use this instead of annotaitons.

   /**
     * @ORM\Id
     * @ORM\Column(type="string")
     */
    protected string $hash;
    /**
     * @ORM\Column(type="string")
     */
    protected string $type = '';
   #[ORM\Id]
   #[ORM\Column]
    protected string $hash;
   #[ORM\Column]
    protected string $type = '';
driehle commented 1 year ago

This is already supported for quite a while. Just make sure that in your entity configuration (https://www.doctrine-project.org/projects/doctrine-orm-module/en/5.3/user-guide.html#entities-settings) you are using Doctrine\ORM\Mapping\Driver\AttributeDriver and not Doctrine\ORM\Mapping\Driver\AnnotationDriver.

Feel free to provide a PR to update the documentation.