Tag: php

  • Php Backed Enums don’t forget to call value

    Php Backed Enums don’t forget to call value

    The one thing I don’t like about new PHP enums is, if you forget to call ->value you get exceptions “object can’t be converted to string” It is entirely too easy to forget to call ->value. This means in places where I refactor code I have to remember to call ->value. Hence the article title […]

  • Working with your apps local image assets in Symfony 5+

    Working with your apps local image assets in Symfony 5+

    This article is mostly about managing your apps personal images and SVG files that it uses in your User Interface. It also explains how the Assets system works to the best of my abilities and discoveries. This is the best info about assets, I have found in the docs about assets. It doesn’t mention some […]

  • How to secure individual Symfony AJAX api routes without using API Platform

    How to secure individual Symfony AJAX api routes without using API Platform

    I am in the process of updating this article entirely. Please stay tuned. Creating the Symfony route is easy. Checking if the request was sent by AJAX is again easy. But what stops a mischievous hacker from hitting that endpoint and trying to get a list of used emails or something else with a script? […]

  • Symfony 5.3+ how to use Sessions with RequestStack

    So some changes happened in Symfony 5.3. Previously you could get to a session with either Session or SessionInterface. Some didn’t like how that worked so now it is moved to RequestStack. The docs or article are not correct here. It shows you get to the session like this. $session = $this->requestStack->getSession(); But that doesn’t […]

  • Symfony 5+ how to make a form field hidden from display

    Symfony 5+ how to make a form field hidden from display

    This is easier than it sounds, but I am writing this in case I need to remember what the answer is. At first I wasn’t paying attention to all of the many different Symfony form types in this long list.  I totally didn’t see the HiddenType in the list or I didn’t notice it. I […]

  • How to change the id for a form input in Symfony 5+

    How to change the id for a form input in Symfony 5+

    If you create your forms with classes in Symfony 5+ then changing the ID of the form fields is something you are not allowed to do apparently. LOL You can add/change the class and other attributes but not the id. For some reason Symfony ONLY lets you change the id inside the template. I don’t […]

  • How to add placeholder text to a Symfony 5+ form row

    How to add placeholder text to a Symfony 5+ form row

    If you are using the Symfony forms system, which I assume you are if you are here, then this post is for you. Otherwise you figure it out. LOL There is more than one way to do this. However, I am going to show the way I prefer and that is right in the form […]

  • How to access Doctrine in Symfony 5+ services

    How to access Doctrine in Symfony 5+ services

    Scroll down to the answer part if you just want the answer. From what I can tell the Symfony documentation only shows how to access doctrine in your controllers( I am sure it is somewhere). But what if you need to access it in a service? Services are any class within a folder inside the […]

  • How to create 100+ Symfony 5+ Doctrine 2 or 3 Repositories

    How to create 100+ Symfony 5+ Doctrine 2 or 3 Repositories

    Scroll to the bottom to view a video of this Repository maker in action. I make about 100 Repositories in less than 2 minutes. You can go faster by just hitting enter really fast. LOL NOTE – repository in the sense of this article means a Doctrine Repository Object. This object is used to interact […]

  • How to install Redis with Docker for local testing

    How to install Redis with Docker for local testing

    In another article I suggest installing Redis with docker but do not tell how. In this article I cover how to get a Redis Image up and running with Docker locally. First you need to install Docker for your system.  After you have Docker installed, next you need to download a Redis image. Here is […]