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 ...
Final config Migration
... also delete config_prod.yml.
Oh, by the way, if you have some doctrine caching config in config_prod.yml,
I would recommend not migrating it. The DoctrineBundle recipe gives you prod
configuration that is great for ...
Migrating framework Config
... validation line!
What's really interesting is that enable_annotations is set to true because
it detected that we have the Doctrine annotations package installed. This is the
flow with Flex: install a package and you're done.
Ok! It might not look like it, but we're almost done with the framework stuff.
Let's finish it next!
Exceptions Part 2 Adding Fence Security
... .. unless there's
some security to keep it inside.
We've reached the third step of TDD once again: refactor. Actually, I don't need
to refactor, but now is a great time to add the missing Doctrine annotations.
Above the ...
Tests Assertions Coding
... property. It does have Doctrine annotations,
but that's not important! Sure, we will eventually be able to save dinosaurs to
the database, but our test doesn't care about that: it just checks to make sure
setting and ...
2725
Doctrine
Filter Results