511 search results

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
The Request Object

…Request object. And there are two ways to get it. The first is by autowiring a service called RequestStack. Then you can get the current request by saying $requestStack->getCurrentRequest(). This works anywhere that you can autowire a service. But in a controller, there's…

9:07
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
URL to Public Assets

…feel like a micro improvement, but it's awesome! Thanks to this, we can call getPublicPath() from anywhere in our app to get the URL to an uploaded asset. If we move to the cloud, we only need to change the URL here! Awesome! Except..…

7:44
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 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
Creating & Mapping Layouts

…Until we actually included {% block layout %} in base.html.twig, the layout was loading... we just weren't rendering it anywhere. The takeaway is this: if you're on a page that does not map to a layout, everything is exactly the same as always…

11:31
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
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
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
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
Filtering to Return only Approved Answers

…So... let's do that! In the Question class... anywhere, but right after getAnswers() makes sense, create a new function called getApprovedAnswers(). This will return a Collection, just like getAnswers(): Collection is the common interface that ArrayCollection and PersistentCollection both implement. Inside, we're going…

9:40
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
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
Behat for Testing

…To see it, run the same command with a -dl option: $ php vendor/bin/behat -dl Anywhere you see the quote-parentheses mess that’s a wildcard that matches anything. So as long as we write scenarios using this language, we can test without…

4:35
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
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
Passing Props vs Fetching Directly

…talk about that in our Vue 3 tutorial. Anyways, in this situation, because categories is boring and static, it doesn't really need to live as data anywhere. And that means, we do not need to pass it down as props. If we want to…

6:36