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..…
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…
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…
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…
New Component to Hold our Form
…Now that we have a proper class, we don't need to put
handleFormSubmit() inside of render() anymore. Nope, we can access the props
from anywhere as this.props.
So, copy that function & the const, paste it in the class, turn it into a property,…
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…
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…
HttpKernel::handle() The Heart of Everything
…thing to take-away here is that there is a try-catch block. This means that
if you throw an exception from anywhere inside your application - like a
controller or a service - it’s going to get caught by this block. And when
that happens…
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…
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…
Twig
…s added automatically to any page
that has a valid HTML structure. That's why we didn't see it until we extended
the layout file.
Click anywhere on it to multiply the amount of information it gives you by
100! This is the profiler…
Introduction
…First, download Selenium Server,
which is just a jar file that can live anywhere on your computer. Start
Selenium at the command line by running java -jar followed by the filename.
$ java -jar selenium-server-standalone-2.28.0.jar
Now for the magic…
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…
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…
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…
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…
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…
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…
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..…
Immediately Invoked Function Expression!
…that function is its home.
Before, when we weren't inside of any function, our two variables effectively
became global: we could access them from anywhere. But now that we're inside of
a function, the RepLogApp and Helper variables are only accessible from inside…
x
512