517 search results

Parameters

…dir? And we'll set its value to __DIR__: That doesn't do anything, but now we can use that root_dir parameter anywhere else when we're building the container. To use a parameter in Yaml, say %root_dir%: With everything in Yaml, we…

3:29
The Query Builder

…accidentally remove something you added earlier. So, always use andWhere(). Doctrine is smart enough to figure out that, because this is the first WHERE, it doesn't actually need to add the AND. Inside of andWhere(), pass mix.genre =... but don't put the…

10:04
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
Resetting a Forgotten Password

…In production you'd get the email, but in development, by default, Symfony's mailer doesn't actually send anywhere - it tracks them in the profiler though! It won't be on this request, because we were redirected, so it's on the redirect response…

10:49
Logging in with a Username or Email

…not the username. That's because our User entity implements UserInterface, which has getUserIdentifier() and we're using the email for that. So anywhere a user identifier is shown, it's going to be the email. If you have public-facing stuff, don't use…

5:21
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
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
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
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
Security Voter & Entity Permissions

…do have control over that query. Open up UserCrudController and, anywhere, I'll go near the top, override a method from the base controller called createIndexQueryBuilder(). Here's how this works: the parent method starts the query builder for us. And it already takes into…

8:36
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
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
Twig ❤️

…See this Welcome? No surprise, that's the current title of the page. Because this is surrounded by a block, we can override that in any template. Check it out: anywhere in show.html.twig, add {% block title %}, Question, print the question, then {% endblock %}. This…

10:14
HTML dialog for Modals

…Actually, we can put it down here on the dialog. Add a new action: click->modal#clickOutside: I bet that looks odd - it'll be called whenever we click anywhere in the dialog - so let's go write that method. Say clickOutside(), give it an…

13:18