The symfony2 documentation says that in the EntityManager :: getRepository method, the argument must be a string literal in the format 'SomeBundle: EntityName'

However, this method normally accepts the literal in the standard form of the full class name.

As you know, any php class supports the "magic" method :: class , which returns this most complete name.

It seems to me that it is more correct to use the class and its magic method. So refactoring is easier, and the transition to the class in the IDE can be done.

As a result, the "right" and more convenient?

  • By the name of the bundle. - etki

1 answer 1

If we talk about IDE, then if you use PHPStorm + Symfony2 plugin, then you will not have problems with refactorings.

In principle, you can use the Entity::class method if you prefer, but keep in mind that when using repositories as services, you will not be able to use such a construction in services.yml , and there you will have to either insert the full class name or the short name BlogBundle:EntityName .

Choose the appropriate method. But if you are writing using the symfony2 framework, it is better to use its “native” ( BundleName:EntityName ) methods.