513 search results

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
Logout & Passing API Data to JS on Page Load

…small HTML to bootstrap the Vue app... though I am doing one interesting thing: I'm passing a prop to Vue called entrypoint. I'm not using this anywhere... but it's a cool example: entrypoint is the URL to our documentation "homepage". In theory…

8:49
Form Theme Block Naming & Creating our Theme!

…Instead, open form_div_layout.html.twig and find the block there. Copy that and, in register.html.twig, paste this anywhere. Hmm - let's remove the wrapping

and see if this works! Deep breath - refresh! I saw something move! Inspect the form and..…

6:22
Tags, Compiler Passes & Other Nerdery

…it can! But we need to set this up in our bundle. Open the extension class, go anywhere in the load() method, and add $container->registerForAutoconfiguration(WordProviderInterface::class). The feature that automatically adds tags is called autoconfiguration, and this method returns a "template" Definition object…

9:07
Services

…is this: everything is done by a service. If you learn to master services, you can do anything from anywhere in Symfony. There's a lot more to say about the topic of services, and so many other parts of Symfony: configuration, Doctrine & the database…

7:24
Twig ❤️

…the block some default content, like with title: Yep, the browser tab's title is Welcome. Let's override that! At the top... or really, anywhere, add {% block title %}. Then say Read , print the title variable, and {% endblock %}: Try that! Yes! The page title changes…

8:23
Handling 404's + other Errors

…It's so nice when things work. What we just did is huge. If a 404 exception is thrown anywhere in the system, it'll map to the nice Api Problem format we want. In fact, if any exception is thrown it ends up with…

6:25
Global RESTful Exception Handling

…name. And we don't need to have a return statement anymore: just call the function and it'll throw the exception for us: Re-test everything: Now we're green and we can send back exciting error responses from anywhere in our code. But…

6:55
Requiring Authentication

…were with us for episode 1, we did some pretty advanced error handling stuff at the bottom of this Application class. What we basically did was add a function that’s called anytime there’s an exception thrown anywhere. Then, we transform that into a…

6:32
Customizing Error Pages and How Errors are Handled

…an exception happens. We haven’t talked about events yet, but this basically means that if you want, you can be nofitied whenever an exception is thrown anywhere in your code. Why would you do this? You might want to do some extra logging or…

6:01
Block Plugins

…the page... absolutely nothing happens! We added those options... but we're not using them anywhere yet. We need to override a template to do that. Let's think: we want this top and bottom margin to apply to every block in the system. And…

10:15
Frontend Item View

…or, in a little while, we could choose to manually select the exact recipes to show. We can also now embed lists and grids of recipes anywhere we want on the site. To celebrate, remove the entire latest_recipes Twig block: And, up in MainController…

7:41
Enhanced Docker Integration & Testing Emails

…Refresh, add a fake email address, register, and... it worked! Of course, it didn't send the email anywhere... but we can still see, more or less, what the email would look like. How? Click any link to go into the Profiler, click "Last 10"…

10:57
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
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
Persisting to the Database

…with DateTime objects. Let's say new \DateTime() and add some randomness here too: sprintf('-%d days') and pass a random number from 1 to 100. So, the askedAt will be anywhere from 1 to 100 days ago. Ok! Our Question object is done! Add…

8:42
Autowiring Dependencies into a Service

…is something that we're gonna to do over and over again. The benefit is that we now have a beautiful service - a tool - that we can use from anywhere in our app. We pass it the markdown string and it takes care of the…

6:45
Secrets Management Setup

…you have an environment variable that you want to convert to a secret, you need to fully remove it as an environment variable: do not set it as an environment variable anywhere anymore. I'll remove MAILER_DSN from .env and if we were overriding…

9:35
Database Tricks on SymfonyCloud

…out of SSH, and run: symfony tunnel:open I love this feature. Normally, the remote database isn't accessible by anything other than our container: you can't connect to it from anywhere else on the Internet. It's totally firewalled. But suddenly, we can…

8:00
Map and WeakMap

…southernUSStates to null: When you try it now, this of course prints "undefined". That makes sense: we're now passing null to the get() function. But what you can't see is that the southernUSStates object no longer exists... anywhere in memory! Why? In JavaScript…

7:20