511 search results

JOINs

…we want to JOIN across this fortuneCookies property over to the FortuneCookie entity. Let's do it! Back over in CategoryRepository... we can add the join anywhere in the query. Unlike SQL, the QueryBuilder doesn't care what order you do things. Add ->leftJoin() because…

3:45
Extensión de consulta: Autofiltrar una colección

…to modify the query for a collection endpoint, we're going to create something called a query extension. Anywhere in src/ - I'll do it in the ApiPlatform/ directory - create a new class called DragonTreasureIsPublishedExtension. Make this implement QueryCollectionExtensionInterface, then go to "Code"->"Generate…

6:15
Mapear Activos

…how about, templates/base.html.twig. Anywhere - I'll go above the body block - add an img with src="{{ asset() }}" passing this the path to our file relative to the assets/ directory. So images/penguin.png. That's it. This is known as the "logical…

6:01
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
Acceder a los datos de un ManyToMany

…droid names in two spots, so let's add a smart method for this in the Starship class. This could go anywhere, but I'll stick it at the bottom with the other droid methods. Create a public function getDroidNames(): string. To return a comma…

2:48
Filtros: Modificar consultas automáticamente

…it is a two-step process. First, in config/packages/doctrine.yaml, we need to tell Doctrine that the filter exists. Anywhere directly under the orm key, add filters and then fortuneCookie_discontinued. That string could be anything... and you'll see how we use…

6:59
Cuando falla la autenticación

…to your users - you can do this. Open up config/packages/security.yaml. And, anywhere under the root security key, add a hide_user_not_found option set to false: This tells Symfony to not convert UserNotFoundException to a BadCredentialsException. If we refresh now... boom…

7:19
Publicar-Suscribir (PubSub)

…constructor arguments... it's just not something I care about all that much. It does look cool though. Down here, anywhere before our app actually starts, say $this->eventDispatcher->. Notice that the only method this has is dispatch(). I made a... tiny mistake. Let…

6:18
configureCrud()

…by id descending. To do that, open DashboardController and, anywhere inside, go to Code -> Generate - or command+N on a Mac - select override methods and choose configureCrud(). The Crud object has a bunch of methods on it... including one called setDefaultSort(). That sounds handy…

5:38
State in your Controller

…usable methods in my controller as possible. The nice thing about setSelectedColor() is that it's not dependent on the event: before we were reading event.currentTarget. Now, anyone can call this method from anywhere, pass a color id and... everything will just work! Well…

6:26
SRP: Responsibilities

…code that deals with hashing passwords and persisting user data? In a perfect world, shouldn't I be able to create this "email resend" feature without going anywhere near code that's unrelated to this functionality? This is what SRP is trying to help us…

6:24
Setting up with the Symfony Local Web Server

anywhere, I'll move this into a global bin directory. By the way, you only need to do these steps once on your computer... so you're done forever! Unless we've mucked things up, we should now be able to run this from anywhere

5:15
Creando un Nuevo Proyecto de Symfony 5

…downloads a single executable file and, for me, puts it into my home directory. To make it so that I can run this executable from anywhere on my system, I'll follow the command's advice and move the file somewhere else: Ok, try it…

6:05
Having Fun with the Menu

…but this time leave the label blank. So unlike sub-menus, which wrap menu items, you can just pop a section anywhere that you want a separator. Let's go check it out. Refresh and... very nice! Separator one says "Content"... and separator two gives…

3:25
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
Negar el acceso en un controlador

…it lives in AbstractController. This method is so beautifully boring: it creates and returns a new AccessDeniedException. This exception is the key to denying access, and you could throw it from anywhere in your code. Close that... and then go refresh. Yup, we get the…

4:57
Symfony UX & Chart.js

…I've already created that page at "/admin"... but it's not very interesting yet... and none of these links go anywhere. Ok: let's check out the docs for Symfony UX chartjs. Scroll down... Whoa. Stimulus and Chart.js are both pure JavaScript libraries…

7:48
Parameters

…the container. Invent a new one called, how about, cache_adapter set to cache.adapter.apcu: There should now be a new parameter in the container called cache_adapter. We're not using it anywhere... but it should exist. How do we use it? There…

7:59
Creating a Service

…which we will later. So how do we create our very own service? Start by creating a class anywhere in src/. It doesn't matter where but I'll create a new sub-directory called Service/, which I often use when I can't think…

5:03
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