1000 search results

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
Validating how Values Change

…what they originally looked like. So, we are going to solve this with validation... but with the help of a special class from Doctrine called the UnitOfWork. Alrighty, let's whip up a test to shine a light on this pesky bug. Inside tests/Functional/…

8:30
Auto Setting the "owner"

…for this: the state processor system. As a reminder, our POST and PATCH endpoints for DragonTreasure already have a state processor that comes from Doctrine: it's responsible for saving the object to the database. Our goal will feel familiar at this point: to decorate…

4:19
Querying for a Single Entity for a "Show" Page

…is that this returns a VinylMix object. Unless you do something custom, Doctrine always gives us back either a single object or an array of objects, depending on which method you call. Now that we have the VinylMix object, let's render a template and…

8:55
The Query Builder

…have... so you might accidentally remove something you added earlier. So, always use andWhere(). Doctrine is smart enough to figure out that, because this is the first WHERE, it doesn't actually need to add the AND. Inside of andWhere(), pass mix.genre =... but…

10:04
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
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
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
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
Events, Events & Events!

…see the Twig templates being executed below it, and even little Doctrine queries happening along the way. The biggest thing I want you to notice is that most of the other lines - both before and after the controller - contain the word Listener, or sometimes Subscriber…

5:10
AssociationField for a "Many" Collection

…Question: That method properly removes the Answer from Question. But more importantly, it sets $answer->setQuestion() to null, which is the owning side of this relationship... for you Doctrine geeks out there. Ok, try removing "95" again and saving. Hey! We upgraded to an error…

6:28
Pagination on a Custom Resource

…Second, to return the count of the total number of items. When you use Doctrine, it executes 2 separate queries for this: one to fetch the current page's results with a LIMIT and OFFSET, and a second COUNT query to count every row. Ok…

8:18
Simpler State Processor

…to it. The other way - which we did in the last tutorial for this class - is to decorate the core processor. Here, we decorated the PersistProcessor from Doctrine... which means that whenever any API resource is saved, when it tries to use the core PersistProcessor…

5:47
Async & Retryable Sending with Messenger

…sent to be queued. We'll use the Doctrine transport as it's easiest to set up. composer require symfony/doctrine-messenger Back in our IDE, the recipe added this MESSENGER_TRANSPORT_DSN to our .env and it defaulted to Doctrine - perfect! This transport adds…

3:39
Totally Custom Fields

…is loaded. For example, our classes are already using a Doctrine state provider behind the scenes to query the database. We'll cover state providers in part 3 of this series. The second solution would be to use the custom normalizer like we did, then…

3:24
Mapping Messages to Classes in a Transport Serializer

…I did! I mean, handling messages asynchronously... that's pretty fun stuff. The great thing about Messenger is that it works brilliantly out of the box with a single message bus and the Doctrine transport. Or, you can go crazy: create multiple transports, send things…

4:56
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
Saving Relations

…passing the ID to the question property, we're setting the entire Question object onto the property. Doctrine will be smart enough to save these in the correct order: it'll save the question first, grab its new id, and use that to save the…

3:58
Relations in Foundry

…Notice that, in getDefaults(), we are not setting the question property. And so, if you spin over to your terminal and run: symfony console doctrine:fixtures:load ... we get our favorite error: question_id column cannot be null. To fix this, in AppFixtures, pass a…

4:41
Fetching Relations

…inside the Question entity, the $answers property will not be a true array of Answer objects. Nope, it will be some sort of Doctrine collection object. It may be an ArrayCollection object or this PersistentCollection object... just depending on the situation. It doesn't really…

6:58