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 ...
Priming cache.app
... automatically makes
available. You can also use cache.adapter.filesystem - which is the default -
doctrine, apcu, memcached or create your own service. If you need to configure
Redis, use the default_redis_provider key under app ...
Safe Migrations
...
./bin/console doctrine:migrations:diff
Go check it out in app/DoctrineMigrations. Wow... it's actually perfect:
ALTER TABLE video CHANGE image (to) poster...
Doctrine is smart ...
Void Types Refactoring an Entire Class
... flexible interface. But actually, for Doctrine collections,
you must use Collection. Depending on the situation, this property might be an
ArrayCollection or a PersistentCollection... both of which implement the
Collection ...
Using a Test Database
... do that, we can setup the test environment to use a different database
name. Open config.yml and copy the doctrine configuration. Paste it
into config_test.yml to override the original. All we really want to
change is ...
Weird Endpoint The tagline as a Resource
... should be /api/programmers/{nickname}/tagline.
To be super hip, add an @Method annotation: we know this should only match PUT requests:
Like before, type-hint the Programmer argument so that Doctrine will query for
it for ...
Pagerfanta Pagination
... () - since we're using Doctrine - and pass it
the query builder. Next, create a $pagerfanta variable set to new Pagerfanta()
and pass it the adapter.
On the Pagerfanta object, call setMaxPerPage() and pass it 10. And then ...
Adding to a Collection Cascade Persist
... Genus.genusScientists that
was not configured to cascade persist operations for GenusScientist.
Umm, what? Here's what's going on: when we persist the Genus, Doctrine sees the
new GenusScientist on the genusScientists array... and ...
Tracking Cancelations in our Database
... () and then saving it to the database with
the standard persist() and flush() Doctrine code:
And that should do it! Let's give this guy a try. Go to the account page, then press
the new "Cancel Subscription" button. Ok ...
Give the User a Subscription in our Database
... $stripeSubscription->id:
Booya!
And, time to save this to the database! Since we're using Doctrine in Symfony, we
need the EntityManager object to do this. I'll use dependency injection: add an
EntityManager argument to the ...
2729
Doctrine
Filter Results