Skip to content

Tag: symfony5

Symfony 5.4 Form: Issue with EntityType custom query_builder orderBy(‘rand’) and setMaxResult

I’m struggling with a ‘strange’ behavior. When I use setMaxResult() + Rand() on my query_builder. I got randomly the message that my value is not valid. SymfonyComponentValidatorConstraintViolation {#1320 ▼ -message: “Cette valeur n’est pas valide.” -messageTemplate: “This value is not valid.” -parameters: [▶] -plural: null -root: SymfonyComponentFormForm {#911 ▶} -propertyPath: “children[press]” -invalidValue: “8” -constraint: SymfonyComponentFormExtensionValidatorConstraintsForm {#987 …} -code: “1dafa156-89e1-4736-b832-419c2e501fca” -cause:

New alternative for getDoctrine() in Symfony 5.4 and up

As my IDE points out, the AbstractController::getDoctrine() method is now deprecated. I haven’t found any reference for this deprecation neither in the official documentation nor in the Github changelog. What is the new alternative or workaround for this shortcut? Answer As mentioned here: Instead of using those shortcuts, inject the related services in the constructor or the controller methods. You

Customize new authentication errors messages on Symfony5.3

on my new symfony 5.3 project i just implemented the new authentication system, and it works fine, but my problem is that i can’t customize the authentication errors: in the method: onAuthentificationFailure in the AbstractLoginFormAuthenticator but in my view it only displays the session error which is normal since my controller calls the getLastAuthenticationError() method. but how could I display

Check JWT (Firebase) Token with Symfony 5.3

I’m working on an API, and I had implemented a JWT to make it stateless. I created an AuthController, which returns a JWT when login information is correct. Here you can see the return code that generates the token: This is the result when I run the authenticate method, un the URL localhost:8000/authenticate. Now, what I would need to do

Symfony 5.2.11: Problem with creating Custom Access Decision Manager

I am trying to create a Custom Access Decision Manager by implementing AccessDecisionManagerInterface on Symfony 5.2. Symfony recognizes the decision manager and instantiate it, but it doesn’t pass Voters array to decision manager. So it can’t collect votes, however the default decision manager works fine. I have followed the information provided on Symfony website. I have also copied the decision

Symfony 5 / Doctrine: Sorting entity collection by creation DateTime

I am developing a project using Symfony 5. One of my use-cases involves reading a collection from the Database, with the items sorted by creation order, descending (newest first). I am using the “Timestampable” extension from “stof/doctrine-extensions-bundle” to save the createdAt and updatedAt timestamps in my entity. According to Doctrine documentation, I can sort items ussing the Repository methods: This

Symfony autowire/autoconfigure not working

I created a symfony 5.3 api. My plan is to inject the “EntityManager” via “EntityManagerInterface”. Error that comes: My services.yaml My CreateUserAccountController.php in src/Controller/: My composer.json: I know that I dont use the Manager, but it doesn´t work for me. The webserver I use: symfony cli webserver Has anyone a idea, where the problem is? Answer This is actually a