You are browsing a version that has not yet been released. |
Doctrine Annotations replaced by native PHP attributes, see Attributes Reference.
If you are still using annotations, you can migrate your code to attributes by following the guide below:
Change the metadata driver configuration to use the AttributeDriver:
- use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationsDriver;+ use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver;- $config->setMetadataDriverImpl(AnnotationsDriver::create(__DIR__ . '/Documents'));+ $config->setMetadataDriverImpl(AttributeDriver::create(__DIR__ . '/Documents'));
Replace the @ODM\Document annotations with the #[ODM\Document] attribute.
use Doctrine\ODM\MongoDB\Mapping\Attribute as ODM;- /**- * @ODM\Document- */+ #[ODM\Document]class User{- /**- * @ODM\Id- */+ #[ODM\Id] public string $id;- /**- * @ODM\Field(type="string")- */+ #[ODM\Field(type: "string")] public string $name;}
|
You can use Rector to automate the migration process. See How to Upgrade Annotations to Attributes for more information. |
