Aliases & When Autowiring Fails
…wrong. Right now, the
MarkdownTransformer class has two arguments, type-hinted with MarkdownParserInterface
and Cache from Doctrine:
But, these are not being autowired: we're explicitly specifying each argument:
If I were creating this service today, I actually wouldn't specify any configuration
at first…
Criteria System: Champion Collection Filtering
…But if - in our template, for example - we wanted to loop over the experts,
maybe to print their names, Doctrine would be smart enough to make a SELECT statement
for that data, instead of a COUNT. But that SELECT would still have the WHERE clause…
Create Genus Note
…again! Welcome back friend! In this tutorial, we're diving back into
Doctrine: this time to master database relations. And to have fun of course - databases
are super fun.
Like usual, you should code along with me or risk 7 years of bad luck. Sorry…
Data Persister: Encoding the Plain Password
…users, we need to be able to run
some code after API Platform deserializes the JSON into a User object, but
before it gets saved to Doctrine. That code will encode the plainPassword
and set it on the password property.
How can we do that…
Adding a Comment Entity
Hey friends! I mean, hello fellow space-traveling developer... friends. Welcome,
to part two of our Doctrine tutorial where we talk all about... relationships.
Oh, I love relationships, and there are so many beautiful types in the universe!
Like, the relationship between two old friends…
Adding the ManyToOne Relation
…to have many Comments... and we want each Comment to
belong to one Article. Forget about Doctrine for a minute: let's think about how
this should look in the database. Because each Comment should belong to one
article, this means that the comment table…
Owning Vs Inverse Relations
We need to talk about a very, very important and, honestly, super-confusing part
of Doctrine relations! Listen closely: this is the ugliest thing we need to talk
about. So, let's get through it, put a big beautiful check mark next to it, then…
Dynamic Roles and Canonical Fields
Let's see what this all looks like in the database! To query the user table,
we can actually use the console:
php bin/console doctrine:query:sql 'SELECT * FROM user'
Nice! We inherited a bunch of columns from the base User class, like username…
Keep Going!
…was probably the most important episode yet,
and you made it. Congrats!
The first big piece included the two main Doctrine associations: ManyToOne
and ManyToMany. We saw how each can have an optional inverse side, like
the OneToMany side of ManyToOne.
The second huge piece…
An Aside: Dependency Injection Parameters
…forms stuff and open config.yml. Under
the doctrine key, we see a bunch of percent sign values:
# app/config/config.yml
# ...
doctrine:
Whenever you see something surrounded by two percent signs in a config file,
it’s a parameter. Parameters are like variables: you…
OneToMany: The Inverse Side of a Relationship
…we gave every Event an owner. This was our first Doctrine relationship:
a ManyToOne from Event to User.
This lets us do things like call $event->getOwner(). Let’s use this to
print the owner of an Event:
{# src/Yoda/EventBundle/Resources/views/Event/show…
Fixtures: For some dumb data
…it
there:
To see if it's working, try getting help information on a new doctrine:fixtures:load
console task that comes from the bundle:
php app/console doctrine:fixtures:load --help
We see the help information, so we're ready to write some fixtures…
Starting in Symfony2: Course 2 (2.4+)
…we're going to take you through some of the most difficult areas of Symfony learning all about security, forms, and parts of Doctrine. We'll also see testing and learn more about how Symfony's service container works. When you get to the end…
Upgrading to Symfony 8
…edges that pop up along the way. And along the journey, we’ll tackle one of the biggest ecosystem shifts: upgrading Doctrine to take advantage of PHP 8.4’s native lazy proxies - goodbye generated proxy classes, hello simpler, faster magic.
Whether you’re maintaining…
Tracking & Fixing Deprecations
…s coming from Doctrine, something about raw field value
access... But look at this! A link to a pull request right in the message! Very
helpful, I love it! Copy the link and paste it in your browser...
This is the Doctrine PR that modified…
Pagination
…s a generic pagination library
but has great Doctrine integration! Add the two required packages:
composer require babdev/pagerfanta-bundle pagerfanta/doctrine-orm-adapter
Scroll up to see what this installed. pagerfanta/doctrine-orm-adapter is the glue between
Pagerfanta and Doctrine.
On our homepage…
Migrations
…it's a PHP class where the up() method holds the SQL to create our table.
What's neat is how this was created: Doctrine compared the current state of our
entities to the database and generated the SQL needed to make them match.
Wow…
Symfony Forms: The Basics
…this course, you’ll learn how to:
Install and configure the Symfony Form component
Build form types with Maker and map them to Doctrine entities
Understand the difference between Form and FormView
Render forms and fields using Twig’s helper functions
Use form_start(), form…
x
1000+