06.
Query for a List of Genuses
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
14 Comments
Should we use $em->getRepository(Genus::class) to get the repository? I think this is the new sf3 way. (?)
Hey!
Either way is Ok! You'll start to see this ::class syntax more in Symfony 3 simply because this syntax is new to PHP 5.5, and Symfony 3 is the first version that required PHP 5.5 (so we couldn't show this syntax in the documentation before Symfony 3). But yea, I kinda like this syntax - I think it's a little more "obvious" or understandable than AppBundle:Genus.
Cheers!
Yeah, using the Genus::class is much better than the 'AppBundle:Genus' magic string.
Totally! and the best part (at least to me) is, it works with refactoring tools
It's genera, not genuses. :P
we know :) - but probably most people won't. I did "sneak in" one use of "genera" in the fixtures like :) http://knpuniversity.com/sc...
hi weaverryan
can u tell me how can i connect my symfony3 with mongodb i am new to this technologies
Hey Honey,
There's a third-party bundle: DoctrineMongoDBBundle. It helps you to use Symfony with Mongo DB. You have to install this bundle with Composer. Unfortunately, we have not had a screencast about this bundle yet - it's only in our plans, but you can take a look at their official docs to get started with it quickly: https://symfony.com/doc/cur...
Cheers!
I actually had to use "return new Response(dump($genuses));" to make it working.
Hey Luka,
Well, it's in case your want to print the dump output, but... you probably don't :) Because it's printed not on the page but in the Symfony Web Debug Toolbar - look for the "target" icon. Or, you can click on this icon and you will be redirected to the "Dumped Contents" tab of profiler where your dump output will be expanded full page. I bet you just missed it, that's why you think it doesn't work. Dump's output is printed on the page only when you use it in Twig templates.
Cheers!
Sorry, just can't make it work, here is the error below, what does it mean?
Attempted to load class "GenusRepository" from namespace "AppBundle\Repository".
Did you forget a "use" statement for another namespace?
Hey James,
There is a problem of mapping between your directories and namespaces. You should double-check the namespace of "GenusRepository" class. Is it really has "namespace AppBundle\Repository;" namespace? Is this file really located in "src/AppBundle/Repository/GenusRepository.php" path?
Also look closely for spelling, maybe you missed some letter or just make a typo in it? Let me know if it doesn't help you.
Cheers!
Thanks, I really tried everything and even looked at the final file result and everything seems alright. I don't know why it is trying to get this namespace as I am not even calling it...
Here is a quick print screen:
http://jamesdavison.io/prin...
Ah, I think I know what's problem.
Open "Genus" entity, most probably you have a repository class specified there, right?
If no - it's weird, then, in PhpStorm, right click on "src/" folder, choose "Find in path" and search for "GenusRepository". PhpStorm will find all usage of GenusRepository class in your code in the src directory and you could remove it.
"Houston: no signs of life"
Start the conversation!