Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctrine ORM documentation example Product entity wrong annotation definition #7686

Closed
wajdijurry opened this issue Apr 20, 2019 · 8 comments
Assignees
Milestone

Comments

@wajdijurry
Copy link

wajdijurry commented Apr 20, 2019

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
@AkenRoberts
Copy link

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.

@SenseException
Copy link
Member

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.

@wajdijurry
Copy link
Author

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
Copy link
Author

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 :\

@SenseException
Copy link
Member

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.

@wajdijurry
Copy link
Author

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

@SenseException
Copy link
Member

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

@lcobucci
Copy link
Member

Handled by #7753

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants