Doctrine ORM documentation example Product entity wrong annotation definition #6227

Closed
opened 2026-01-22 15:29:13 +01:00 by admin · 8 comments
Owner

Originally created by @wajdijurry on GitHub (Apr 20, 2019).

Originally assigned to: @lcobucci on GitHub.

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
Originally created by @wajdijurry on GitHub (Apr 20, 2019). Originally assigned to: @lcobucci on GitHub. ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | no | Version | 2.6.2 #### Summary <!-- Provide a summary describing the problem you are experiencing. --> 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. <!-- What is the current (buggy) behavior? --> 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 <!-- Provide steps to reproduce the bug. --> 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```
admin added the Documentation label 2026-01-22 15:29:13 +01:00
admin closed this issue 2026-01-22 15:29:13 +01:00
Author
Owner

@AkenRoberts commented on GitHub (Apr 25, 2019):

Hi @wajdijurry. The examples in the docs are accurate. Are you actually receiving an error for Doctrine\ORM\Annotation class not existing? Any other specific error, or just the "No Metadata Classes to process." message?

Also, where did you put the bootstrap.php file? The docs are vague on that, but it should be at the root of the project.

@AkenRoberts commented on GitHub (Apr 25, 2019): Hi @wajdijurry. The examples in the docs are accurate. Are you actually receiving an error for `Doctrine\ORM\Annotation` class not existing? Any other specific error, or just the "No Metadata Classes to process." message? Also, where did you put the `bootstrap.php` file? The docs are vague on that, but it should be at the root of the project.
Author
Owner

@SenseException commented on GitHub (May 2, 2019):

The Product entity example is using the annotation classes in the 2.6 docs without importing them with use and an "ORM" alias.
Doctrine\ORM\Annotation is a 3.0 namespace and therefore part of the master branch and the 3.0 docs. This is correct.

@wajdijurry Do you like to create a PR for the documentation of 2.6.

@SenseException commented on GitHub (May 2, 2019): The Product entity example is using the annotation classes in the 2.6 docs without importing them with `use` and an "ORM" alias. `Doctrine\ORM\Annotation` is a 3.0 namespace and therefore part of the master branch and the 3.0 docs. This is correct. @wajdijurry Do you like to create a PR for the documentation of 2.6.
Author
Owner

@wajdijurry commented on GitHub (May 2, 2019):

The Product entity example is using the annotation classes in the 2.6 docs without importing them with use and an "ORM" alias.
Doctrine\ORM\Annotation is a 3.0 namespace and therefore part of the master branch and the 3.0 docs. This is correct.

@wajdijurry Do you like to create a PR for the documentation of 2.6.

Yes sure.

@wajdijurry commented on GitHub (May 2, 2019): > The Product entity example is using the annotation classes in the 2.6 docs without importing them with `use` and an "ORM" alias. > `Doctrine\ORM\Annotation` is a 3.0 namespace and therefore part of the master branch and the 3.0 docs. This is correct. > > @wajdijurry Do you like to create a PR for the documentation of 2.6. Yes sure.
Author
Owner

@wajdijurry commented on GitHub (May 7, 2019):

Hi @SenseException ,

It seems that the online docs is for doctrine ORM v3.0, but it says to install doctrine ORM v2.6.2, so for which version should I open a new PR ? since it seems that I did not got your last comment :\

@wajdijurry commented on GitHub (May 7, 2019): Hi @SenseException , It seems that the online docs is for doctrine ORM v3.0, but it says to install doctrine ORM v2.6.2, so for which version should I open a new PR ? since it seems that I did not got your last comment :\
Author
Owner

@SenseException commented on GitHub (May 8, 2019):

For the 2.6 branch because of the imported annotations.

If there is 2.6 mentioned in the 3.0 docs, this should fixed too in a separate PR.

@SenseException commented on GitHub (May 8, 2019): For the 2.6 branch because of the imported annotations. If there is 2.6 mentioned in the 3.0 docs, this should fixed too in a separate PR.
Author
Owner

@wajdijurry commented on GitHub (May 9, 2019):

For the 2.6 branch because of the imported annotations.

If there is 2.6 mentioned in the 3.0 docs, this should fixed too in a separate PR.

But the bug is invalid for v2.6, since the annotation class is not imported and it is used without an alias

@wajdijurry commented on GitHub (May 9, 2019): > For the 2.6 branch because of the imported annotations. > > If there is 2.6 mentioned in the 3.0 docs, this should fixed too in a separate PR. But the bug is invalid for v2.6, since the annotation class is not imported and it is used without an alias
Author
Owner

@SenseException commented on GitHub (May 10, 2019):

Because in the examples of 2.6, the annotation classes, like @Entity or @Column aren't imported.

@SenseException commented on GitHub (May 10, 2019): Because in the examples of 2.6, the annotation classes, like `@Entity` or `@Column` aren't imported.
Author
Owner

@lcobucci commented on GitHub (Sep 12, 2019):

Handled by #7753

@lcobucci commented on GitHub (Sep 12, 2019): Handled by #7753
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6227