andWhere() and orWhere()
…ve ever used it! And... you shouldn't either. Using andWhere()
is always ok - even if this is the first WHERE clause... and we don't really
need the "and" part. Doctrine is smart enough to figure that out.
What's wrong with ->where()? Well…
And WHERE Or WHERE
…cat:
The only thing our query needs is a WHERE clause to match the term to the
name of the Category. Let's chain!
Use a function called andWhere(). Don't worry - Doctrine won't add an
AND to the query, unless it's needed…
Generating URLs
Most of these links don't go anywhere yet. Whatever! No problem! We're going to
fill them in as we continue. Besides, most of our users will be in hypersleep for
at least a few more decades.
But we can hook up some of…
Symfony End-to-End Testing: WebTestCase to Playwright
…real JavaScript.
Along the way, we'll cover:
Unit vs integration vs end-to-end tests: what each one is good at and where they fit
WebTestCase and Symfony's built-in functional testing tools
zenstruck/browser for expressive, fluent browser tests
Creating exactly the…
Actions: Listening to Events
I want to make our controller more realistic: instead of being able to click
anywhere on the element to increment the count, let's add a button.
Easy enough! In the template, add
Migrating Encore -> AssetMapper
…bunch of interesting things. We won't go too deep into how
AssetMapper works - we have other tutorials for that - but let's explore.
In .gitignore:
it ignores the final location of the built assets and where
the vendor files live. And in templates/base…
Listening & Publishing
…which is the template that
holds the entire reviews turbo frame. At the top, or really anywhere, add a div.
Where its attributes live, render a new Twig function from the UX library we
installed a few minutes ago - turbo_stream_listen() - and pass this…
encore watch & Code Splitting
…filenames? When you build Encore for production,
those will be very simple names, usually a number - like 55.js. It won't expose
all these path details.
Next let's figure out how and where stimulus is installed and build our very
first stimulus controller!
Collection Magic with Criteria
…you can chain off of this. The Criteria object is similar to the QueryBuilder
we're used to, but with a slightly different, well, slightly more confusing syntax.
Add andWhere(), but instead of a string, use Criteria::expr(). Then, there
are a bunch of methods…
Filters
…cookie company, that means we don't
make them anymore. But we're not showing this information anywhere on the
frontend yet.
But what if we wanted to only show fortune cookies on the site that we're
still making? In other words, where discontinued…
Reusing Query Logic & Param Converters
…you can reuse query logic between them. For example, a lot
of queries might need this andWhere('q.askedAt IS NOT NULL') logic. That's not
complex, but I would still love to not repeat this line over and over
again in every method and…
Multiple Submit Buttons
…If we change price to IntegerType::class, when we refresh the form,
nothing will change, because that was the guessed type.
But what built-in form field types does Symfony have and where can we find
them? Great question, and I'm glad you asked…
Criteria: Filter Relation Collections
…of an entity. Fortunately, we can move
it there.
Because this deals with fortune cookies, open
FortuneCookieRepository and, anywhere, add a new public static function called...
how about createFortuneCookiesStillInProductionCriteria(). This will return a
Criteria object.
Now, grab the $criteria statement from the entity... and return…
Bonus: Messenger Monitor Bundle
…When you have a bunch of messages and schedules running in the background,
it can be hard to know what's happening. Are my workers running? Is my schedule
running? And where is it running to? What about failures? I mean, we have logs,
but..…
Modal Twig Component
…a good day. Today we get to combine our modal system with Twig components
to achieve a goal! I want to be able to quickly add a modal anywhere in our app.
Start in base.html.twig. All the way at the bottom, copy the…
RESTful APIs in the Real World Course 1
…PUT, PATCH, DELETE
Idemptotency and safe methods
Proper Status Codes, Location header and Content-Type
Testing your API
RFCs and where the "rules" come from
Advanced error and validation handling
If you want to know about Hypermedia, HATEOAS,
Content-Type negotiation, pagination and more, these…
Turbo Stream Responses
For day 24, strap in for a quick adventure. We've learned that Turbo Streams are
custom HTML elements that you can throw onto the page anywhere... and they execute!
But there's another way to use Streams that's actually more commonly-documented,
even…
Webpacking our First Assets
…the final, built files and the second - setPublicPath() -
tells it the public path to this directory:
The third important piece, and where everything truly starts, is addEntry():
Here's the idea: we point Webpack at just one JavaScript file - assets/js/app.js.
Then, it…
All about Event Bubbling
I'm feeling so good about our first click listener, let's add another! When I click
anywhere on a row, I also want to log a message.
Back in the template, give the entire table a js class so we can select it. How…
Security Fundamentals
…really powerful. Honestly,
it’s also really complex. It can connect with other authentication systems
like Facebook or LDAP - or load user information from anywhere, like a
database or even across an API.The bummer is that hooking all this up can be tough. But…
x
513