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…
Doctrine’s QueryBuilder
Doctrine’s QueryBuilder¶
What if we wanted to find a User by matching on the email or username
columns? We would of course add a findOneByUsernameOrEmail method to
UserRepository:
// src/Yoda/UserBundle/Entity/UserRepository.php
// ...
class UserRepository extends EntityRepository
{
}
To make queries, you can use…
Doctrine & the Database in Symfony 4
…put our new skills to the test! It's finally time to make up app come alive by using Doctrine to connect to a database.
Doctrine is an amazing ORM that works great with Symfony and is super powerful. It also has a reputation for…
Doctrine Collections: ManyToMany, Forms & other Complex Relations
…Counting collections in the EXTRA_LAZY way
Rendering relationship data from both sides
Filtering collections efficiently with Criteria (mind will be blown)
Dealing with complex collection forms
Adding "extra" data to the "join table"
Doctrine relationships take a little bit more work to get setup…
Installing Doctrine
…added an empty migrations/ directory, an empty src/Entity/ directory,
and an empty src/Repository/ directory. We'll dive into all of these one-by-one.
Ok! We have Doctrine installed, so we can talk to databases... except that... we don't
actually have a…
Symfony, Doctrine Relations & Warp Drive Basics
…of a relation
Filtering a collection of related objects with Criteria
orphanRemoval (not as heartless as it sounds!)
Querying with Joins
Solving the N+1 problem
ManyToMany Relations
ManyToMany with extra data on the join table
Your mission: tackle Doctrine relationships... without crashing the ship…
Simple Doctrine Data Fixtures
…fixtures, in a sense, via this new action. But Doctrine has a system
specifically designed for this.
Search for "doctrinefixturesbundle" to find its GitHub repository. And you can
actually read its documentation over on Symfony.com. Copy the install line and,
at your terminal, run…
Installing Doctrine
…username and password.
What uses this environment variable? Excellent question! Check out a new file
the recipe gave us: config/packages/doctrine.yaml. Most of this config you
won't need to think about or change. But notice this url key: it reads
that DATABASE…
Sluggable: Doctrine Extensions
…a feature, you need to enable it in this config file.
The first behavior we want is sluggable. To enable it add orm: - because we're
using the Doctrine ORM:
and then default:, because we want to enable this on our default entity manager.
That…
Installing Doctrine
…to our tutorial about learning Spanish! What?
That's next week? Doctrine?
Ah: welcome to our tutorial all about making Symfony talk to a database... in
English.
We learned a ton in the first two courses of this series, especially the last
tutorial where we…
ManyToOne Doctrine Relationships
ManyToOne Doctrine Relationships¶
Right now, if I creat an Event, there’s no database link back to my user.
We don’t know which user created each Event.
To fix this, we need to create a OneToMany relationship from User
to Event. In the database…
Installing Doctrine
…the database
the_spacebar:
Of course, this sets a DATABASE_URL environment variable. And it is used in
a new config/packages/doctrine.yaml file that was installed by the recipe. If
you scroll down a bit... you can see the environment variable being used…
Mastering Doctrine Relations in Symfony 4!
In the part 1 of the Doctrine Tutorial we created a freakin' awesome setup: with Doctrine: entities, queries, migrations and fixtures.
But, we're missing a big, giant, huge, important piece! Database relations! And once you've mastered these, you'll be unstoppable! But... a…
Mastering Doctrine Relationships in Symfony 3
…of the Doctrine Tutorial
we got a sweet setup with Doctrine: entities, queries, migrations and fixtures.
But, we left out one big piece: database relations. Once you've mastered these,
you'll be unstoppable. Unfortunately, a lot of information out there make Doctrine
relations look…
Track
Learn Doctrine
Working with databases doesn’t have to be painful. Doctrine lets you think in objects while it handles the messy SQL details behind the scenes.
In this track, we’ll start from the basics — entities, repositories, and migrations — and work our way up to relationships…
Routing with Doctrine Inheritance
Let's create a dedicated show page for our starships and check out how
routing works with Doctrine inheritance entities. We first need a new controller,
so hope over to the terminal and run:
symfony console make:controller Starship
No need for any tests. Alright…
Go Pro with Doctrine Queries
You already know how to query with SQL, so learning how to do complex queries with Doctrine should not be a pain! In this tutorial, we'll learn about:
the language Doctrine speaks (DQL)
the QueryBuilder object
JOINs! And using them to reduce queries
SELECTing…
Symfony 5: Mastering Doctrine Relations
In the part 1 of the Doctrine Tutorial we got some serious work done with Doctrine: creating entity classes, making custom queries, migrations, Docker setup & more!
But... we ignored one of the biggest part of Doctrine: relations / associations! And thanks to tooling inside of Symfony…
Go Pro with Doctrine Queries (Legacy)
…with Doctrine should not give you a headache. In this series,
we'll learn the language Doctrine speaks (DQL), as well as the query
builder object, how to use complex query features and even how to run
good ol' fashioned raw SQL queries with Doctrine…
x
1000+