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 ...
API Platform Installation
... that helps install several thing at once.
Heck, you can see this at https://github.com/api-platform/api-pack: it's a single
composer.json file that requires several libraries, like Doctrine, a CORS
bundle that we'll talk ...
Unique but not Insane Filenames
... storing spaces or... most
weird characters on a filesystem. But if you want to guarantee cleaner filenames,
there's an easy way to do that. I'll use a class called Urlizer: this comes from
the gedmo/doctrine-extensions ...
Buzzwords Specification Examples
... want
to organize your code. But, if you're used to Doctrine in Symfony, this will feel
familiar.
Ok! One new file: DinosaurSpec.php. Let's go check it out! Ok - so phpspec creates
a spec/ directory, which is meant to ...
Tweak your Form based on the Underlying Data
...
second argument to createForm(). You do this sometimes if you want to pre-fill
a "new" form with some default data. The form system would update that Article
object, but Doctrine would still be smart enough to insert a new ...
Agree to Terms Database Field
... Doctrine does
not record it as having been executed. That makes sense. And because there is
only one statement in this migration, we know that it completely failed, and we
can try it again as soon as we fix it. In other words ...
EntityType Drop-downs from the Database
...
we'll see in a minute how we can control what's displayed here.
So... great first step! It looks like the form guessing system correctly sees the
Doctrine relation to the User entity and configured the EntityType for us. Go ...
Bind Your Form to a Class
... type guessing" system - tries to guess the proper
"type" for each field. It notices that the $content property on Article is a longer
text Doctrine type. And so, it basically says:
Hey peeps! This content field looks ...
Impersonation switch_user
... session at the beginning
of each request. But it is also used by a few other features to load the user,
like remember_me and switch_user. If you're using the Doctrine user provider
like we are, then this property key ...
Security the User Class
... "No" for now. We will add a password later, but we'll keep
things extra simple to start.
And... we're done! Awesome! This created a User entity, a Doctrine UserRepository
for it, and updated the security.yaml file.
Let's check out these changes next!
Linking Symfony deps to your Local Copy
...
run:
composer require annotations
This installs sensio/framework-extra-bundle... we only technically need
to install doctrine/annotations. But, that's ok. Restart the built-in web ...
The 4 2 Possible Relation Types
... Profile and
User entities, then the profile table would have a user_id foreign key to
the user table. The only difference is that doctrine would make that column
unique to prevent you from accidentally linking multiple ...
Request Object Query OR Logic
... right places. One mistake could lead to an OR causing many more results
to be returned than you expect!
To best handle this in Doctrine, always use andWhere() and put all the OR logic
right inside: c.content LIKE :term OR ...
Twig Block Tricks
This tutorial is all about Doctrine relations... plus a few other Easter eggs
along the way. And one big topic we need to talk about is how to create queries
that join across these relationships. To do that properly ...
Query Logic Re-use Shortcuts
... hint - the one from Doctrine\ORM - and $qb:
Next, go up, copy that part of the query, and just return
$qb->andWhere('a.publishedAt IS NOT NULL'):
And since we're returning this - and each query builder method returns ...
Sluggable other Wonderful Behaviors
...
slug is unique. So, if a slug already exists in the database, it adds a -1
, -2, -3, etc. until it finds an open space.
Side note: this feature is built on top of Doctrine's event system. Google for
"Doctrine Event ...
Services
...
There's a lot more to say about the topic of services, and so many other parts
of Symfony: configuration, Doctrine & the database, forms, Security and APIs, to
just name a few. The Space Bar is far from being the galactic ...
2708
Doctrine
Filter Results