make:docker:database
Doctrine is installed! Woo! Now we need to make sure a database is running - like
MySQL or PostgreSQL - and then update the DATABASE_URL environment variable
to point to it.
So: you can absolutely start a database ...
How Entity Controller Arguments Work
... But where 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 ...
Events Events Events
... request-response process. You can see - kind of in
the middle here - is our controller: it took 36 milliseconds to execute. You
can see the Twig templates being executed below it, and even little Doctrine
queries ...
Processing Encore Files through inline_css
... ". You can learn
about this in, oddly-enough, our
tutorial about Symfony & Doctrine.
To fetch the service, go down to getSubscribedServices() and add
EntrypointLookupInterface::class.
Back up in getEncoreEntryCssSource ...
Recommendations
... radar.
There's also a recommendation that Doctrine annotation metadata should be cached
in production. Honestly... I'm not sure why that's there - Symfony apps come with
a config/packages/prod/doctrine.yaml file that takes ...
Async Emails with Messenger
... - called "messages" - will be sent. Messenger
calls these transports. Because we're already using Doctrine, the easiest "queueing"
system is a database table. Uncomment that MESSENGER_TRANSPORT_DSN to use it.
Next, open ...
Unit Testing our Emails
... we mock the User object? We could, but as a general rule, I like to mock
services but manually instantiate simple "data" objects, like Doctrine entities.
The reason is that these classes don't have dependencies and it's ...
Serializing Messages as JSON
... messenger.transport.symfony_serializer.
When a message is sent to a transport - whether that's Doctrine, AMQP or something
else - it uses a "serializer" to encode that message into a string format
that can be sent. Later, when it reads a ...
Resetting the Database Between Tests
... each other. It was the inspiration behind a fixture class that we created and
used in our Symfony Doctrine
tutorial. The recipe creates a fixtures/ directory for the YAML files and a new
command for loading that data.
But ...
Logging in Inside the Test
... doctrine then say ->getManager().
You can also use the type-hint you use for autowiring as the service id. In
other words, self::$container->get(EntityManagerInterface::class) would work
super well. And actually... it's ...
Login with json_login
... the
last tutorial for us by the make:user command. It tells the security system
that our User lives in Doctrine and it should query for the user via the email
property. If you have a more complex query... or you need to ...
Testing with the in-memory Transport
... 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/. This gives us messenger ...
Investigating Retrying Failed Messages
... it should do it. Also, not all the transport types - like AMQP or Redis -
support all of the features we just saw if you use it as your failure transport.
That may change in the future, but at this moment - Doctrine is ...
Installing Messenger
... creates a new ImagePost
entity, saves it to the database with Doctrine and then, down here, we have
some code to add Ponka to our photo. That ponkafy() method does the really
heavy-lifting: it takes the two images ...
Removing Items from a Collection
... CheeseListings in this array suddenly... are not
in this array, Doctrine will delete them. Just, realize that if you try to
reassign a CheeseListing to another User, it will still delete that
CheeseListing. So, just make sure you ...
Creating the User Entity
... check the SQL: CREATE TABLE user - looks good!
Run it with:
php bin/console doctrine:migration:migrate
Perfect! We have a gorgeous new Doctrine entity... but as far as API Platform ...
PropertyFilter Sparse Fieldsets
... hydra:search.
Filters are super fun. Tons of filters come built-in, but you can totally add
your own. From a high-level, a filter is basically a way for you to modify the
Doctrine query that's made when fetching a collection ...
User API Resource
... that's supported by Doctrine and API Platform. UUIDs work with
any database, but they are stored more efficiently in PostgreSQL than MySQL,
though we use some UUID's in MySQL in some parts of SymfonyCasts.
But... why am ...
SerializedName Constructor Args
... because of a new feature that can automatically convert your database
rules - the fact that we've told Doctrine that title is required in the
database - into validation rules. Fun fact, this feature was contributed to ...
Our First ApiResource
... cheese_listing...
Yea! Looks good! Close that and run:
php bin/console doctrine:migrations:migrate
Brilliant! At this point, we have a completely traditional Doctrine entity ...
2725
Doctrine
Filter Results