1000 search results

Cascade Persist

…and... we can now see when each droid was assigned. That's it, friends! We've explored the deepest corners of Doctrine relationships, even the elusive many-to-many with extra fields. As always, if you have questions, drop them in the comments below. We…

2:51
Re-adding addDroid(): Hide that Join Entity!

…This one is pretty common in Doctrine, though not always easy to understand: A new entity was found through the relationship Starship#starshipDroids that was not configured to cascade persist for the entity StarshipDroid. This is a very fancy way of saying we've created…

1:46
Joining Across a Many-to-Many Relationship

…add a leftJoin(). But we're not going to think about the join table or the database. Nope, focus only on the relationships in Doctrine. So we're joining across s, which is our starship, and droids, the property that has the ManyToMany relationship to…

2:17
Quick! Create a DragonTreasure DTO

…And finally, remove the custom DragonTreasureStateProvider and DragonTreasureStateProcessor classes. But we did keep one thing: DragonTreasureIsPublishedExtension. Because the new system will still use the core Doctrine CollectionProvider, this query extension stuff will continue to work and be called. That's just one less thing we…

9:51
Builder in Symfony & with a Factory

…character builder needed a service like the EntityManager? With our new setup, we can make that happen. I don't actually have Doctrine installed in this project, so instead of the EntityManager, let's require LoggerInterface $logger... and I'll again add private in front…

8:18
Customizing the User Class

…roles and first_name columns. Close this... and run it: symfony console doctrine:migrations:migrate Success! And because the User entity is... just a normal Doctrine entity, we can also add dummy users to our database using the fixtures system. Open up src/DataFixtures/AppFixtures…

3:08
Sending Handlers to Different Transports: from_transport

…for the options you can pass here... though you can always check MessageSubscriberInterface: it talks about what's available. Next, let's up our queueing game by changing from the Doctrine transport to RabbitMQ - also commonly referred to as AMQP. It's buckets of fun!

3:21
High Priority Transports

…which in our case is using doctrine. Below, add options, then queue_name set to high. The name high isn't important - we could use anything. The queue_name option is specific to the Doctrine transport and ultimately controls the value of a column in…

5:40
File Upload Field in a Form

…will not work. Pretty commonly, you'll see people create this property on their entity, just to make the form work. They don't persist this property to the database with Doctrine... so the idea works, but I don't love it. Instead, we'll…

9:09
Warmup Command Configuration

…the parent class if we detect that it's a proxy. After creating the ReflectionClass, write if ($class->implementsInterface(Proxy::class)). Import the class from Doctrine\Persistence: All generated proxies have this interface. Inside, write $class = $class->getParentClass() to get the true entity class: …

5:26
Writable Collection via the PropertyAccessor

…into why we can't have a setter, but it relates to the fact that we need to set the owning side of the Doctrine relationship. We talk about this in our Doctrine relations tutorial. The point is, if we were able to just call…

6:29
Using RAND() or Other Non-Supported Functions

…t change anything in our app... it just adds a bunch of code that we can activate for any functions that we want. To do that, back over in config/packages/doctrine.yaml, somewhere under orm, say dql. There are a bunch of different categories…

3:11
WHERE IN()

…but inside of that, instead of a comma-separated list, you'll set an array. Doctrine will transform that for us. And now... nice! Once you know how it works, it's just that easy. Next: You're probably familiar with the RAND() function for…

2:07
docker-compose & Exposed Ports

…Thanks to some magic between Docker and the Symfony binary, this is going to be super easy. To start, remember when the Doctrine recipe asked us if we wanted Docker configuration? Because we said yes, the recipe gave us docker-compose.yml and docker-compose…

6:53
Dynamic Roles

…paste, use abraca_user@example.com... and leave roles empty: Let's do it! At your terminal, run: symfony console doctrine:fixtures:load When that finishes... spin over and refresh. We got logged out! That's because, when the user was loaded from the session…

4:28
Testing with the "in-memory" Transport

…we could query the messenger_messages table, but that's a bit hacky - and only works if you're using the Doctrine transport. Fortunately, there's a more interesting option. Start by copying config/packages/dev/messenger.yaml and pasting that into config/packages/test…

5:26
Testing with Multiple Symfony Versions

…In our composer.json file, for the Symfony packages, this means 6.4.0. For the doctrine-bundle, it would be 2.18.0. To get these lowest versions installed, over in the terminal, run: symfony composer update --prefer-lowest We can see Composer switched…

7:01
Docker & Environment Variables

…cool. By the way, if you want to see all the environment variables the Symfony binary is setting, you can run: symfony var:export --multiline But the most important one by far is DATABASE_URL. Ok: Doctrine is configured! Next, let's create the database…

3:43
Handling Messages Sync while Developing

…And... yea! Because we're currently in the dev environment, both transports have a dsn set to sync://. I do want to mention that the queue_name option is something that's specific to Doctrine. The sync transport doesn't use that, and so, it…

5:54
Using the Filesystem

…that: article_image/ and then $newFilename. I think we're ready! Let's clear out the uploads/ directory again. And then try our fixtures: php bin/console doctrine:fixtures:load Oh! It does not work! Unused binding $uploadsPath in service UniqueUserValidator. This is a bad…

4:11