Integration Tests
... you mock everything... there's
nothing really left to test
For example, how would you test that a complex query in a Doctrine repository works?
If you mock the database connection then... I guess you could test that the ...
Relating Custom ApiResources
... it reads
the Doctrine relationship metadata to figure out that a property is a collection
of some other #[ApiResource] object. Long story short, this is simple
to fix... it's just hard to understand at first. Above the ...
Setup Ways to Extend API Platform
... been
Doctrine entities. And that's fine! But as your API starts to look different from
your entities, making that work adds complexity: serialization groups, extending
normalizers, etc. At some point, it becomes easier and ...
A World without Build Systems
... .. hello Mixed Vinyl! But wow is this thing weird and ugly-looking.
This is a Symfony 6.3 project - the same project we've built in the Symfony series.
It has Doctrine installed... but there's nothing particularly special ...
Reusing Queries in the Query Builder
... (make
sure you get the one from Doctrine\ORM - the "Object Relational Mapper"), and let's
call it $qb. This will also return a QueryBuilder.
The next step is pretty simple. Go steal the JOIN logic from above... and, down ...
Totally Custom Fields
... with a state provider.
We haven't talked about state providers yet, but they're how data is loaded. For
example, our classes are already using a Doctrine state provider behind the
scenes to query the database. We'll cover ...
Removing Items from a Collection
...
property. After cascade, add one more option here: orphanRemoval: true.
This tells Doctrine that if any of these dragonTreasures become "orphaned" - meaning
they no longer have any owner - they should be deleted.
Let's try it ...
Docker Environment Variables
...
symfony var:export --multiline
But the most important one by far is DATABASE_URL.
Ok: Doctrine is configured! Next, let's create the database itself via a bin/console
command. When we do that, we'll learn a trick for doing this with the environment
variables from the Symfony binary.
MakerBundle Autoconfiguration
... make section. Ooh. There's a ton of stuff here for setting up
security, generating doctrine entities for the database (which we'll do in the next
tutorial), making a CRUD, and much more.
Let's try one: how about we try to ...
Recipe Upgrades Part 2
Run:
composer recipes:update
Next up is doctrine-extensions-bundle. This one... when we look... just modified
a comment! Easy!. So commit that... and then move onto debug-bundle ...
Annotations to Attributes
...
Next, let's add property types to our entities. That's going to allow us to have
less entity config thanks to a new feature in Doctrine.
QuestionTag Fixtures DateTimeImmutable with Faker
...
datetime_immutable Doctrine type. This means that, instead of that property
being a DateTime object, it will be a DateTimeImmutable object. Really...
the same thing... except that DateTimeImmutable objects can't be changed.
The ...
JOINing Across Multiple Relationships
...
Question and Tag. Doing that is legal in SQL... but it messes up how
Doctrine creates the objects, so it doesn't allow it.
The solution is easy enough: select both. You can actually pass an array to
addSelect() to select ...
Foundry Always Pass a Factory Instance to a Relation
I love Foundry. But using Foundry with Doctrine relationships is probably the
hardest part of this library. So let's push a bit further. Pretend that, in this
situation, we want to override the question value. Right now ...
Mercure Pushing Stream Updates Async
...
yet! That's like installing Doctrine... but without MySQL or Postgresql running!
So next, let's get the Mercure service running. There are a bunch of ways to do
this. But if you're using the Symfony binary web server like we are... then...
it's already done!
UUID as a API Identifier
... And when you
use Doctrine, API Platform assumes that you want the database id as the identifier.
To tell it to use something different, add @ApiProperty() with identifier=false:
That says:
Hey! Please don't use this ...
Core Listeners Accessing the Resource Objects
... the isMe field... that's probably fine... because nobody is the
currently-authenticated user in a console command anyways. But if you did
want a custom field to be populated everywhere - even in a console command - we
have one more solution: a Doctrine postLoad listener. Let's check that out next!
How does the Controller Access the Container
...
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 ...
Prod Vault Optimization Vault for Tests
... feature called "validation auto mapping".
It's a wicked-smart feature that automatically adds validation constraints based
on your Doctrine metadata and also based on the way that your PHP code is written
in your class.
2725
Doctrine
Filter Results