517 search results

Exposing more Error Details

…Look back at our exception-handling function. The NotFoundHttpException is not an instance of ApiProblemException, so we fall into the situation where we create the ApiProblem by hand. We’re not using the exception’s message anywhere, so it makes sense we don’t see…

4:56
Handling 404 Errors

…JsonResponse and set the application/problem+json Content-Type header on it. Now, if an exception is thrown from anywhere in the system for a URL beginning with /api, the client will get back an API problem response. It took a little bit of work…

6:17
ApiProblemException and Exception Handling

…notice that the status code is still 400. Our new exception class extends HttpException, so we really have the same behavior as before. When an exception is thrown anywhere in our app, Silex catches it and gives us an opportunity to process it. In fact…

5:38
Routing: The URLs of the World

…pull it in. So, even though Symfony only reads this one routing file, we can pull in routes from anywhere. So what's up with the @EventBundle magic? The resource should just point to the path of another file, relative to this one. But if…

5:44
Injecting Config & Services and using Interfaces

…if we needed to use the mailer object somewhere else in our app? Right now, we would need to create it anywhere we need it, since it's buried inside FriendHarvester. In fact, FriendHarvester doesn't really care how we're sending emails, it only…

5:28
Patrón de mando

…hard to maintain, and we won't really be able to reuse this code anywhere else. There has to be a better way to do this... and there is - with the command pattern. We can group the logic of each button into its own command…

3:41
Mensaje flash y modelos ricos vs anémicos

…Symfony will remove them so that they won't render again on the next page load. By putting this in the base template, we can now set flash messages from anywhere in our app and they'll be rendered on the page. Pretty cool. Watch…

6:32
Jerarquía de roles

…a pain in the butt! Fortunately, Symfony has a feature just for this called role hierarchy. Open up config/packages/security.yaml and, anywhere inside of here... but I'll put it near the top, add role_hierarchy. Below this, say ROLE_ADMIN and set…

5:37
Sistema de eventos de seguridad y protección Csrf

…a CSRF token... then, on submit, you validate that token. Let's do this. Anywhere inside your form, add an input type="hidden", name="_csrf_token" - this name could be anything, but this is a standard name - then value="{{ csrf_token() }}". Pass this the string…

6:40
Props: Passing Info into a Child Component

…dev tools are even more interesting! If you click on , you can still see the legend data, though, we're not using this anywhere at the moment. And when you click on , nice! You can see its props! We've just seen two…

4:49
Sub Request Attributes

…argument. If we try, I want an exception to be thrown. By the way, it is actually possible to use the RequestStack from anywhere to get the "master" request: it has a getMasterRequest() method. But! If you're using HTTP caching with edge side includes…

9:05
Autobús turístico

… We're returning a value from our handler! This is not something that we've done anywhere else. Commands do work but don't return any value. A query doesn't really do any work, its only point is to return a value. Before we…

8:47
Despliegue y supervisión

…the middle... there's a spot that talks about supervisor. Copy the configuration file. We could put this anywhere: it doesn't need to live in our project. But, I like to keep it in my repo so I can store it in git. In..…

9:08
Probando con el transporte "en memoria

…find it. This... is basically a fake transport. When a message is sent to it, it doesn't handle it or send it anywhere, it stores it in a property. If you were to use this in a real project, the messages would then disappear…

5:26
Middleware

…want to geek out and see how they work. So here's our goal: each time we dispatch a message... from anywhere, I want to attach a unique id to that message and then use that to log what's happening over time to the…

5:59
When Existing Tests Break & Exceptions in __construct()

…fency", whatever that is... true to make it active and $this because it will be attached to this Enclosure. For the addSecurity() method, because we're not using this method anywhere outside of this class, we should technically create it as private. But, I already…

7:20
Mocks & Spies - shouldBeCalledTimes()

…put the assertion stuff after you run your code. Check this out: remove the ->shouldBeCalledTimes() line. Then, anywhere after we call buildEnclosure(), start with $dinosaurFactory->growVelociraptor(Argument::any()) and then ->shouldHaveBeenCalledTimes(2). This does the exact same thing... it's just a different style. Oh…

5:04
Custom Inline Matcher

…How? By creating our own matcher. At the top of your class... or really anywhere, go to the Code -> Generate menu - or Command+N on a Mac - and override a method called getMatchers(). We don't need to call the parent method because its…

5:35
PHP 7, Nginx & MySQL

…mootube.l from our host machine. To handle that, head to your terminal on your main machine - so not the VM - and edit your /etc/hosts file. Inside, anywhere, add 192.168.33.10 mootube.l. Save that! Back at the browser test it: http…

6:09
Practicing BDD: Plan, then Build

…icon: Other than some easy-win styling, I want to do as little work as possible to get each step of the scenario to pass. Refresh: there's the button. It doesn't go anywhere yet, try it: This time, it did click "New Product…

8:09