Développement web

jQuery, Webpack and Symfony | Call jQuery in your twig files

Uncaught ReferenceError: jQuery is not defined If you encountered this error message in your console of a Symfony project using Webpack, it is very likely that you are using jQuery in the following way in your project :  Your case In the app.js file you probably called jQuery like this : And then you wanted to call in your twig jQuery file this way …

jQuery, Webpack and Symfony | Call jQuery in your twig files Lire la suite »

Symfony, Doctrine | Retrieve old data of FormType

Method for recovering old data from a FormType under Symfony You need to recover old data from an Entity in Symfony to do some processing such as managing a history or other? I will present you a method that uses Unit Of Work to compare old data of data sent via the form created by FormType. Use Unit Of Work from Doctrine To retrieve old data it is …

Symfony, Doctrine | Retrieve old data of FormType Lire la suite »

JavaScript, jQuery et Regex | Secure a password in real time with JS

Here is how to secure a password in front with JavaScript coupled with jQuery and regular expressions (Regex) : Do you want to check in front that the user has entered 8 characters, a number and or a capital letter? I will guide you through the procedure to follow. To follow this procedure you need to have jQuery installed, it is not mandatory, …

JavaScript, jQuery et Regex | Secure a password in real time with JS Lire la suite »

Doctrine, Symfony | Difference between two dates in MySQL (Day, month, year…)

How do I know the difference between two dates in MySQL and Doctrine? You have to use the TimeStampDiff method which takes 3 parameters (the unit, the first date, the second date) and returns a number corresponding to the difference in unit between the dates. For example:  See more details on this link which explains in detail the SQL function TIMESTAMPDIFF How to …

Doctrine, Symfony | Difference between two dates in MySQL (Day, month, year…) Lire la suite »

Symfony FormType Choice | Set data default to group of radio button

How to set a default value to a ChoiceType radio button group under Symfony 4+? Currently you probably use the forms this way: This gives you as a result a group of 3 radio buttons with only one possible choice, but if you put directly here a default value, it will overwrite the values of the entity if you want to change it afterwards. …

Symfony FormType Choice | Set data default to group of radio button Lire la suite »

Symfony, Excel, CSV | Generating a CSV file for Excel with Symfony

It’s a common practice on web applications to extract data via CSV, whether it’s to retrieve statistics or to make data backups, I’ll show you how this is easily done with Symfony via a Controller. How to generate the CSV file with a Symfony Controller To generate the file, it must be constructed as in the following example, by defining the columns of the CSV file with …

Symfony, Excel, CSV | Generating a CSV file for Excel with Symfony Lire la suite »

Angular, ExpressJS | JWT authentication with Angular 10 and ExpressJS 4 (MySQL)

I will assume that you already have your Front with Angular 10 and your Back with ExpressJS 4 and I will not show the creation part of these two projects. Creating the login form under Angular The back side of the form : Go to your form.component.ts file (Make it according to your components…) and we will build it as on the example : We …

Angular, ExpressJS | JWT authentication with Angular 10 and ExpressJS 4 (MySQL) Lire la suite »

Symfony Event Subscriber | Restricting an ip range with an Event Subscriber

Adding an Event Subscriber under Symfony with IP range restriction As part of the tutorial, we will set up an IP range restriction to allow certain IPs, but you can use Event subscriberin any case. An Event subscriber allows us to execute code before entering in our route to a controller for example, it allows us to check certainthings like token connection, …

Symfony Event Subscriber | Restricting an ip range with an Event Subscriber Lire la suite »