1000 search results

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
make:user

…like HumanoidEntity. If the "thing" that logs into your site would be better called a Company or University or Machine, use that name here. Do you want to store user data in the database via Doctrine? For us: that's a definite yes... but it…

5:57
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
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
Filtering Relation Collection

…internally, Doctrine will first query for all 100... even though we'll only return 10. If you have large collections, this can be a performance problem. In our Doctrine tutorial, we talk about fixing this with something called the Criteria system. But with both approaches…

5:39
Query Extension: Auto-Filter a Collection

…we did with the PersistProcessor. Except... that won't quite work. Why? The CollectionProvider from Doctrine executes the query and returns the results. So all we would be able to do is take those results... then hide the ones we don't want. That's..…

6:15
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
How does the Controller Access the Container?

…And AbstractController implements a special interface called ServiceSubscriberInterface. This is actually something we talk about in one of our Doctrine tutorials. When you implement ServiceSubscriberInterface, it forces you to have a method called getSubscribedServices() where you return an array that says which services you need…

4:14
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
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
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
Void Types & Refactoring an Entire Class

…return type to the class you know you're returning... or use the more flexible interface. But actually, for Doctrine collections, you must use Collection. Depending on the situation, this property might be an ArrayCollection or a PersistentCollection... both of which implement the Collection interface…

7:06
Selecting Specific Fields

…s an awesome error: This is what it looks like when you mess up your DQL. Doctrine does a really good job of lexing and parsing the DQL you give it, so when you make a mistake, it'll give you a pretty detailed error…

5:04
Implementing the Webhook Consumer

…method, fetch the user with $user = $this->entityManager->getRepository(User::class)->find($userId). Next, if $user doesn't exist, we'll throw new EntityNotFoundException() (choose the one from Doctrine\ORM). For the message write sprintf('User "%s" not found for LemonSqueezy webhook "%s"!', $userId…

8:10
Dynamic Data

… Up here, we can add a description: Add a column to store the LS variant ID on Product. Back in our terminal, run the migration with: bin/console doctrine:migrations:migrate Now, in src/DataFixtures/AppFixtures.php, set our new field to the variant ID…

6:29
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
Foundry: Fixtures You'll Love

…But first... let's run blindly forward and use this class! In AppFixtures, delete everything and replace it with VinylMixFactory::createOne(). That's it! Spin over and reload the fixtures with: symfony console doctrine:fixtures:load And... it fails! Boo Expected argument type "DateTime", "null"…

7:20
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
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
Hashing Plain Passwords & PasswordCredentials

…try this. Find your terminal and run: symfony console doctrine:fixtures:load This will take a bit longer than before because hashing passwords is actually CPU intensive. But... it works! Check the user table: symfony console doctrine:query:sql 'SELECT * FROM user' And... got it…

4:22