Doctrine
…and
then delete the last part and instead stay as ORM;:
That's the standard use statement that you see at the top of all Doctrine entities.
Let's get rid of these lines here, then get back inside of the class because context]
is…
Doctrine, Symfony 7 & the Database
…This tutorial is all about the database and a library called Doctrine: a powerful ORM that will allow us to talk to a database from inside our Symfony app. With the power of PHP 8 attributes & tools inside Symfony, Doctrine is not only crazy powerful…
Doctrine Inheritance: Classes in the Database
Doctrine makes it possible to map PHP class inheritance directly to your database — but choosing the right strategy (and using it well) is where things get interesting. In this course, you’ll learn how to model shared behavior, specialize entities, and persist complex class structures…
Doctrine DQL
Hey there friends! And thanks for joining me for to a tutorial that's all about the
nerdery around running queries in Doctrine. It sounds simple... and it is for a while.
But then you start adding joins, grouping, grabbing only specific data instead of…
Doctrine Tests
…to configure Doctrine. Add
$builder->loadFromExtension('doctrine', []). First configure dbal with
'url' => 'sqlite:///%kernel.project_dir%/var/data.db':
For the orm configuration, I'm going to paste this snippet (you can grab it
from the script below):
This tells the Doctrine ORM where…
Doctrine Extensions: Timestampable
…new configuration file that we'll look at
in a second.
So this bundle obviously has its own documentation. You can search for
stof/doctrine-extensions-bundle and find it on Symfony.com. But the majority
of the docs live on the underlying DoctrineExtensions library..…
Doctrine, Symfony 6 & the Database
…database time!
This tutorial is all about Doctrine: a powerful ORM that will allow us to talk to a database from inside our Symfony app. With the power of PHP 8 & tools inside Symfony, Doctrine is not only the most powerful ORM in PHP, it…
Doctrine, Symfony & the Database
…or 10!
This tutorial is all about Doctrine: a powerful ORM that will allow us to talk to a database from inside our Symfony app. Historically, Doctrine has sometimes had a reputation for being hard to learn. But with recent changes in the Symfony world…
Doctrine Transaction & Validation Middleware
…ll talk about in
a minute - and an event bus. But each bus has slightly different middleware.
These two middleware - validation and doctrine_transaction - come automatically
with Symfony but aren't enabled by default. If you add the validation middleware,
when you dispatch a message…
doctrine:database:create & server_version
…console
We'll run:
symfony console
symfony console literally means bin/console... but because we're running it
through the Symfony executable, it will inject the environment variables that
are coming from Docker.
So:
symfony console doctrine:database:create
And... boom! We have a database…
Doctrine DQL
…performance.
We'll learn about all of that. And don't worry - if you're good at SQL, you're
going to be great at writing queries in Doctrine.
Our app is a Fortune Cookie inventory system. Yep, we've finally hit the
big time…
Doctrine postLoad Listener
…you know the drill, we're going to add this as a real property in
our entity but not persist it to Doctrine. Call it $isMvp and let's add
some documentation that can be used by the API docs:
Returns true if this user…
Doctrine en dehors des sentiers battus (Romaric Drigon)
L'ORM Doctrine offre beaucoup plus de flexibilité qu'il n'y paraît. Dans cette présentation, nous allons nous intéresser à son fonctionnement interne et à ses fonctionnalités moins connues, pour découvrir comment mieux l'utiliser. Au programme, évènements et listeners, filtres, tracking policy, mais…
Doctrine en dehors des sentiers battus (Romaric Drigon)
L'ORM Doctrine offre beaucoup plus de flexibilité qu'il n'y paraît. Dans cette présentation, nous allons nous intéresser à son fonctionnement interne et à ses fonctionnalités moins connues, pour découvrir comment mieux l'utiliser. Au programme, évènements et listeners, filtres, tracking policy, mais…
Doctrine Listener: Encode the User's Password
…preUpdate. You
might think that these methods would be identical... but not quite. Due to a quirk
in Doctrine, you have to tell it that you just updated the password field, or it
won't save.
The way you do this is a little nuts…
Doctrine is in your Lifecycle (with Callbacks)
… Reload your fixtures and then query to see the
events:
php app/console doctrine:fixtures:load
php app/console doctrine:query:sql "SELECT * FROM yoda_event"
The createdAt column is set so this must be working.
Lifecycle callbacks are brilliant because they’re just so…
Doctrine Event Listeners
…is being saved, we’ll just ignore it. This is important because the function
is called when any entity is saved:
// src/Yoda/UserBundle/Doctrine/UserListener.php
// ...
public function prePersist(LifecycleEventArgs $args)
{
}
Injecting the security.encoder_factory Dependency¶
We’re almost done. You’ve probably…
Doctrine Listeners on Update
Doctrine Listeners on Update¶
But what if a user updates their password? Hmm, our listener isn’t called
on updates, so the encoded password can never be updated. Crap!
Add a second tag to services.yml to listen on the preUpdate event
and create the…
Doctrine Extensions: Sluggable and Timestampable
…but a property that
is automatically cleaned and populated based on the event name.
Installing the StofDoctrineExtensionsBundle¶
Head over to knpbundles.com and search for doctrine extension. The
StofDoctrineExtensionsBundle is what we want: it brings in that DoctrineExtensions
library and adds some Symfony glue to…
x
1000+