[Symfony2] How To detect not found Entity

Hello everyone,

Introduction

I've some news for all of you, I'm back !!! Last weeks resulted in a big change in my life, this is why I was really busy doing lot of not computing related stuff.

Now, it seems that the situation is being more "stable", so I'll have more time to redact tech Posts.

I've found a new job in Paris as a PHP web developer. I'll be working intensively on Symfony2 for the next weeks this is why you'll probably see more posts like this one.

The problem

You've been working on your super brand new Bundle that uses your killer Doctriner Entities and you want to add to your AppKernel.

Great, so you thought that you'll only have to add your Bundle in AppKernel.php bundles array and that's it.

In most of the cases it will work on the first attempt without problem. But in the Murphy's world (the real world) it's not like this.

If you get an error of type :

The class '*Entity' was not found in the chain configured namespaces ...

You've certainly forgot something in your configuration. So follow these simple checks to be sure that everything is alright.

The check list

You'll have to check a bunch of parameters to be sure that everything is alright :
  • Check that Bundle's class name is correct in your AppKernel and in the bundle's root class file.
  • Check that you've added your bundle in config.yml ORM configuration (specially if you had a MappingException error).
  • Check in your routings that Bundle name is correctly typed.
  • Check that you flushed the cache before testing.

Conclusion

Now with these simple checks you'll have no more trouble when adding your brand new killer bundle to take control of the world :)

Have fun.

No comments:

Post a Comment

Merci de votre commentaire. Celui-ci est en cours de modération.

Most seen