512 search results

Search, the Request Object & OR Query Logic

…I'll show you what I mean when we see the final query. The point is that if you need an OR in a WHERE statement, you should still use andWhere(). Yup, we can say: answer.content LIKE :searchTerm OR and then pass another expression…

8:05
Query Joins & Solving the N+1 Problem

…selects from comment, but it does have the INNER JOIN to article! We can now easily reference the article somewhere else in the query. Inside the andWhere(), add OR a.title LIKE :term: That's all you need. Move back and refresh again. It works…

9:01
Request Object & Query OR Logic

…always use andWhere() and put all the OR logic right inside: c.content LIKE :term OR c.authorName LIKE :term. On the next line, set term to, this looks a little odd, '%'.$term.'%': By putting this all inside andWhere() - instead of orWhere() - all of that…

8:44
Joins and addSelect Reduce Queries

…this should be a really easy query. I'll copy the search() function, then simplify things in the andWhere: cat.id = :id. We want to keep the leftJoin() and the addSelect to remove the extra query. Update setParameter to set the id placeholder: The…

6:03
Stimulus: Writing Pro JavaScript

…because modern CSS is amazing. Over on the aside element, add a new CSS class - it could go anywhere - called transition-all. That's a Tailwind class that activates CSS transitions. This means that if certain style properties change - like the width suddenly being set…

8:00
Functions!

…-- index.php -->

Just like your new pup, a function can really go anywhere. And variables can be used as arguments. Remember, $cleverWelcomeMessage represents our string message, so this is the same as passing the string directly…

5:28
Global vs CRUD-Specific Configuration

…ROLE_ADMIN. We'll talk more later about how to secure different admin controllers with different roles... but at the very least, you need to have ROLE_ADMIN to get anywhere, which is awesome. But one important point: adding this access_control was necessary. Why?…

9:13
API Token Scopes

…form, they can still use this operation, even though they won't have that exact role. That is where ROLE_FULL_USER comes in handy. Open config/packages/security.yaml and, anywhere, add role_hierarchy... I recommend spelling it correctly. Say ROLE_FULL_USER. So…

5:51
Popover!

…and paste: Next, create an endpoint for this. In src/Controller/PlanetController.php, anywhere, I'll paste in a route and controller: Nothing special: it queries for the Planet and passes it to the template. In that template, adjust the variables. Instead of voyage.planet…

11:44
Pub Sub Event Class & Subscribers in Symfony

…EventSubscriberInterface and... done! Symfony will automatically register it. To dispatch an event, create a new event class and dispatch that event anywhere in your code. If we try this again (I'll exit the battle first)... it only outputs once. Great! And... what are the…

6:34
Product CRUD

…use for each Category option. Go into src/Entity/Category.php and, anywhere in here - I'll put it at the bottom - add a public function __toString() method that returns $this->name. I'm going to cast that to a string... just in case the…

7:42
Form Submit Confirmation Controller

…the item is gone! But I think we can make this even more awesome. How? By making our controller configurable - like the text that it displays - so we can truly reuse it anywhere in our app. Even in this situation, saying "yes, delete it" on…

6:22
Composer

… By including Composer’s autoloader, the Finder library - as well as the PHP classes for any other libraries we included via Composer - are made available to us automatically. To make our third-party classes available anywhere, it would be even better to include the autoload…

14:00
Testing a Service

…like controllers, repositories & services, nobody is using the LockDownHelper service. We're not autowiring it into a controller or a service anywhere. And so, Symfony removes this from the container... which means that it's not there in the test. The fix for this is…

7:31
Override all the Templates!

…of using the first method to override this - which would work - let's do something different. Copy this template and create our override template... which could live anywhere. How about in templates/admin/field/... and call it id_with_icon.html.twig. Paste the contents..…

6:47
Vue Instance & Dynamic Data

…does exactly what Vue normally does. If you look at this, you might start to wonder: why do we need a template option at all? We're just reading it in render()... so it could live anywhere. Let's try that! Remove the option, and…

6:10
AssociationField for a "Many" Collection

…Yup! Now it's saying: Hey Ryan! Go add that __toString() method! Ok fine! In Answer, anywhere in here, add public function __toString(): string... and return $this->getId(): Now... we're back! And if we type... well... the search isn't great because it's…

6:28
The Entry Point: Inviting Users to Log In

…words: it's making us choose. Copy the entry_point key... then, anywhere under the firewall, say entry_point: and then point to the LoginFormAuthenticator service: Technically we can point to any service that implements AuthenticationEntryPointInterface... but usually I put that in my authenticator. Now..…

6:45
Reliably Load External JS with Stimulus

…At this point, we can add this anchor tag anywhere on our site, and it will instantly do the work to initialize itself. Next: let's investigate the second-use case for Turbo Frames... and really the main use case: the ability to keep navigation…

9:57
Extending a UX Controller

…see if we can let the chart load, wait 5 seconds, then update some data. Start by assigning the chart to a property so we can use it anywhere: this.chart = event.detail.chart. Then, at the bottom, and a new method that will…

8:43