1000 search results

Foundry: Fixture Model Factories

…we deserve better! Let's use a super fun new library instead. Google for "Zenstruck Foundry" and find its GitHub Page. Foundry is all about creating Doctrine entity objects in an easy, repeatable way. It's perfect for fixtures as well as for functional tests…

5:56
How Entity Controller Arguments Work

…is that code? At first, you might think this is another argument value resolver. But, there's nothing in that list that mentions "doctrine" or "entity". In reality, this is working via a different system. If we refresh now, the page still works. But if…

4:54
AMQP Priority Exchange

…in different "queues". Then we can instruct our worker to first read all messages from whatever queue async_priority_high is bound to before reading messages from whatever queue the async transport is bound to. This did work before with Doctrine, thanks to this queue…

7:15
Lean and Mean Dev with PhpStorm (for Symfony)

…lot of the grunt work out of your coding and help you get things done faster: Get the life-changing Symfony plugin Auto-complete namespaces (please stop typing them)! Tricks for annotations, Doctrine, forms, Twig and more Refactoring Live Templates Fast navigation Symfony service integration ...…

10 videos
|
48:53
Joining Across a ManyToMany

…Behind the scenes, to get this data, Doctrine will need to query across the join table and the tag table. But... we don't really care about that! We just get to say question.tags and that returns all the Tag objects for this Question…

5:22
Joining Across a Relationship & The N + 1 Problem

…text. The moment we do that, Doctrine makes a second query from the question table to get that answer's question data: so in this case WHERE id = 463. Then we render the second answer... and make another query to get its question data..…

6:30
Rendering Answer Data & Saving Votes

…templates/question/show.html.twig. If you scroll down a bit - here it is - we loop over the answers variable. That will still work: the Doctrine collection is something that we can loop over. But the answer variable will now be an Answer object. So…

6:02
The ManyToOne Relation

…want to do is relate an Answer to a Question. To do this... well... forget about Doctrine for a second. Let's just think about how this would look in a database. So: each answer belongs to a single question. We would normally model this…

8:35
Custom Filter apply()

…an admin. Why are we talking about these extension classes? Because one of the core Doctrine extensions is called FilterExtension. Let's open it up: Shirt+Shift and look for FilterExtension.php making sure to include all non-project items. Get the one from Orm\…

8:15
Completely Custom Resource

…directory, create a new class called DailyStats: And yes, I'm putting this in the Entity/ directory even though this isn't going to be a Doctrine entity. That's totally allowed and it's up to you if you like this or not. If…

5:25
Publish State Change Validator Logic

… Or true to false? Or maybe it's not changing at all because the PUT request is only updating other fields. And hey! We already know how to get the original data from Doctrine! We did it in CheeseListingDataPersister: Oh, and by the way: if…

8:26
Decorating Data Persisters vs Context Builders

…called just DataPersister. Back in PhpStorm, hit Shift+Shift, search for DataPersister and make sure to include "non-project items". Select the one from ApiPlatform's Doctrine Bridge. And... cool! This looks pretty much exactly like we expected: it persists and flushes. This is what…

8:54
Data Persister Decoration

…object and validates it, it tries to save or persist that object. Usually, this means that we're saving an entity object to the database via Doctrine. But we could "save" an object anywhere, like by sending the data to another API, or putting it…

6:48
Attachments with Async Messenger Emails

…are a bunch of deprecation notices, but the tests do pass. However, run that Doctrine query again to see the queue: Uh oh... the email - the one from our functional test to the registration page - was added to the queue! Why is that a problem…

3:57
Article Admin & Low-Level Access Controls

…you see this "Proxies" thing, ignore it. This is an internal object that Doctrine sometimes wraps around your entity in order to enable some of its lazy-loading relation awesomeness. The object looks and works exactly like User. Second, the error itself basically means that…

7:14
Custom User Method

…the new file: And... yep! It looks perfect. Move back to your terminal one more time and run: php bin/console doctrine:migrations:migrate Excellent! Now that we have the new field, let's set it on our dummy users in the database. Open UserFixture…

6:18
Pagination

…way long. Not only will this page become hard to use, it will quickly slow down until it stops working. If you ever need to query and render more than 100 Doctrine entities, you're going to have slow loading times. If you try to…

9:19
Collection Magic with Criteria

… But... there's a problem. If we did this, Doctrine would query for all of the comments, even though we don't need all of the comments. If your collection is pretty small, no big deal: querying for a few extra comments is probably fine…

7:45
Saving Relations

…to Doctrine. At the top, use the $manager variable: Then, $manager->persist($comment1): If we stop here, this is a valid Comment... but it is NOT related to any article. In fact, go to your terminal, and try the fixtures: php bin/console doctrine:fixtures…

4:35
Activating Timestampable

… First, we need to activate it, which again, is described way down on the bundle's docs. Open config/packages/stof_doctrine_extensions.yaml, and add timestampable: true: Second, your entity needs some annotations. For this, go back to the library's docs. Easy enough…

4:03