Skip to content

Doctrine ORM documentation example Product entity wrong annotation definition #7686

@wajdijurry

Description

@wajdijurry

Bug Report

Q A
BC Break no
Version 2.6.2

Summary

Documentation should be updated, I think it's outdated.

Current behavior

  1. Class "Doctrine\ORM\Annotation" is not exist.
  2. Annotation classes (ORM\Entity) and (ORM\Table) is defined incorrectly, hence annotations are not being parsed.

When annotation parser tries to parse the entity annotations, it does not, since the classes (@Orm\Entity), (@Orm\Table), (@Orm\Id), (@Orm\Column) and (@Orm\GeneratedValue) are not defined.

How to reproduce

Follow the steps described in the documentation:
https://www.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html#what-is-doctrine

  1. Install doctrine via composer v2.6.2
  2. Create entity src/Product.php
  3. Run the command vendor/bin/doctrine orm:schema-tool:update --force --dump-sql
  4. The result is [OK] No Metadata Classes to process.

Expected behavior

The following SQL statements will be executed:

     CREATE TABLE products (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(255) NOT NULL);

 Updating database schema...

     1 query was executed

Fix

  1. No need to import the annotation class
  2. Writing annotations as @Entity instead of @ORM\Entity

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions