I’m working on Symfony 6 PHP 8 project and i’m using gedmo doctrine extension .
I can’t find a full documentation about converting gedmo annotation to PHP 8 Attributes.
I’m tring to convert like this :
/**
* @ORMColumn(type="string", length=255)
* @GedmoSlug(fields={"title"})
*/
private $slug;
#[GedmoSlug(fields: title)]
but it doesn’t work !
How can i use gedmo with PHP 8 Attributes ?
2
Answers
you’ll have to do the whole class property with attributes.
the fields property at slug needs to be an array.
Rector supports this. The rule comes from rector-doctrine, which is included with the standard install method.
Follow the rector install guide and edit the rector.php config to add the required rules.
Rector also has rule sets for updating Symfony to see rector-symfony.
Example of converting the Doctrine and Gedmo annotation to PHP 8 attributes.
e.g. converts this
to