All About services.yaml
…with $product = new Product(). So, these will not
be services in the container.
In the next tutorial, we'll create Doctrine entity classes, which are model classes
for the database. These will live in the src/Entity/ directory... and since
they're not meant…
Unique (but not Insane) Filenames
…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 library. It has a nice method called
urlize() and we can wrap our $originalFilename in…
Listening to LemonSqueezy Javascript Events
…hit. So... did this work?
At your terminal, check the database with:
bin/console doctrine:query:sql "SELECT * FROM user"
It didn't! It says that the lsCustomerId value is "undefined". Hmmm, sounds
like we're using a bad path for the customer ID. If…
Mercure: Pushing Stream Updates Async
…some PHP and JavaScript code that's going to help us
communicate with Mercure. But... we don't actually have a Mercure service running
yet! That's like installing Doctrine... but without MySQL or Postgresql running!
So next, let's get the Mercure service running…
Serializing Messages as JSON
…the keys that you're allowed to have below each transport is called
serializer. Set this to a special string: messenger.transport.symfony_serializer.
When a message is sent to a transport - whether that's Doctrine, AMQP or something
else - it uses a "serializer" to…
Upgrading to Symfony 6.0
…? We get
Attempted the load class QueryAdapter from namespace "Pagerfanta\Doctrine\ORM.
This shouldn't be a surprise... since we did upgrade pagerfanta-bundle from
2.8 to 3.6.
This is a situation where you need to find the GitHub page for the library…
Timeline: Go Behind-the-Scenes with your Code
…not that there are only 3 objects
being hydrated during this request, but that our code asks Doctrine to hydrate one
or more objects on three occasions.
So where are the 3 times that we're hydrating objects? One of the cool things is
that…
API Platform Installation!
…fake" library 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 about later, annotations…
Search, the Request Object & OR Query Logic
…we were already
filtering WHERE status = approved. But because we put the OR statement inside
of the andWhere(), Doctrine surrounded the entire fuzzy search part with parentheses.
If we had used orWhere(), that wouldn't have happened... and our query logic
would have been…
ManyToMany Relation
…that Doctrine is going to handle the
heavy lifting of inserting and removing records to and from this table for us.
We'll see that in a minute.
But before I forget, head back to your terminal and run this migration:
symfony console doctrine:migrations…
Annotations to Attributes
…re back!
With just a few commands we've converted our entire site from annotations to
attributes. Woo!
Next, let's add property types to our entities. That's going to allow us to have
less entity config thanks to a new feature in Doctrine.
Entity objects in Twig
…most recent requests we've made. Here's the one we just made to
/questions/new. Click the little token string on the right to jump into the
full profiler for that request! Go to the "Doctrine" tab and... bam! Cool!
It even wraps the…
Prod Vault Optimization & Vault for Tests
…Next, let's talk about a really cool new feature called "validation auto mapping".
It's a wicked-smart feature that automatically adds validation constraints based
on your Doctrine metadata and also based on the way that your PHP code is written
in your class.
Database Tricks on SymfonyCloud
…main php bin/console doctrine:fixtures:load
Ok, let's break this down. First, there is actually a much easier way to do all
of this... but I'll save that for some future SymfonyCloud tutorial. Basically,
we're running the doctrine:fixtures:load command…
Flysystem & S3
…it should... just kinda work! The easiest way to find out is to reload
the fixtures:
php bin/console doctrine:fixtures:load
And yes, I do recommend using S3 when developing locally if that's what you're
using on production. You could change the…
ManyToMany with Extra Fields
…is still there,
just the way it always was.
If you try to run this migration...it will blow up, with this rude error:
Incorrect table definition; there can be only one auto column...
It turns out, Doctrine has a bug! Gasp! The horror! Yep…
Idempotency, changed_when & Facts
…and paste that below:
So what language happens when there are no migrations to execute? Go to your virtual
machine and run the migrations to find out:
./bin/console doctrine:migrations:migrate --no-interaction
Yes! It says:
No migrations to execute
That's the key…
Themed Pagination Links
…cool!
Ok team! Congratulations on finishing both Doctrine courses! Big team high five!
Doctrine is one of the most important parts of Symfony and it will unlock you
for almost anything else you do. So let us know what cool stuff you're building
and…
Registration Form
…console make:migration
Let's go check out that new file. Yep! No surprises: it just makes the column not
required.
Move back over and run this with:
php bin/console doctrine:migrations:migrate
Excellent! Let's try to register! Register as geordi@theenterprise.org…
Security & the User Class
…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!
x
1000+