Nom de l’auteur/autrice :admin

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 »

JWT authentication with Angular 10 and Node.js/ExpressJS 4 (MySQL)

I will assume that you already have your Front with Angular 10 and your Back with Node.js 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 :

JWT authentication with Angular 10 and Node.js/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 »

VueJS 3, ExpressJS 4.17 | Uploading and resizing an image

Uploading an image and resizing with VueJS 3 and ExpressJS 4.17 I will show you how to make a simple form with VueJS 3, to upload an image and a text field that could be used for the image’s alternative text. The server is running ExpressJS 4.17. We will need several libraries : VueJS Front Back ExpressJS Once the outbuildings are installed, let’s get

VueJS 3, ExpressJS 4.17 | Uploading and resizing an image Lire la suite »

Symfony 5 | Return an image via a controller route

Installation of the road First of all you need a controller with a route ready to receive an image name, and then return the image. Then you need to install the following package: compose require symfony/mime which will allow Symfony to automatically detect the mime type to return. You also need to import these packages on top of the controller. My file tree My image

Symfony 5 | Return an image via a controller route Lire la suite »

Nodemailer : Send a mail with nodemailer and receive it with maildev

Requirements to send an email with nodemailer under NodeJS Install nodemailer from npm : https://www.npmjs.com/package/nodemailer To receive mail locally: https://github.com/maildev/maildev (Useful tools to install globally) To receive mail locally with maildev To receive mail with maildev, you must first launch maildev after installing it globally (npm i maildev -g), then go to a command prompt to type maildev Send the mail with nodemailer  You will

Nodemailer : Send a mail with nodemailer and receive it with maildev Lire la suite »

Symfony 5 | Receive server errors by email with monolog, swiftmailer and maildev

Prerequisites of the tutorial : Install monolog: https://packagist.org/packages/symfony/monolog-bundle (Allows to receive server errors by mail) Install maildev : https://github.com/maildev/maildev (Allows to create a local SMTP server) Install swiftmailer : https://packagist.org/packages/symfony/swiftmailer-bundle (Allows to send mails under Symfony) Configure Monolog : Go to the file monolog.yaml in the folder config/packages/dev (or prod for the prod..) And define the options as in the box below to receive critical errors (so 5XX) but it

Symfony 5 | Receive server errors by email with monolog, swiftmailer and maildev Lire la suite »

Symfony 5 | Send mail with SwiftMailer and Maildev

Prerequisite: Install SwiftMailer: https://symfony.com/doc/5.2/email.htmlInstall Maildev : Configure SwiftMailer : In the file swiftmailer.yaml which is in the config/packages folder we have access to the SMTP url which is in the .env. In the .env change the MAILER_URL. Which will send all mails on port 1025 which is the maildev reception port. Start Maildev : Go to a command prompt and type maildev, the following message will appear

Symfony 5 | Send mail with SwiftMailer and Maildev Lire la suite »

jQuery, Webpack et Symfony | Appeler jQuery dans vos fichiers twig

Uncaught ReferenceError: jQuery is not defined Si vous avez rencontré ce message d’erreur dans votre console d’un projet Symfony utilisant Webpack, il est fort probable que vous utilisez jQuery de la manière suivante dans votre projet :  Votre cas Dans le fichier app.js vous avez surement appelé jQuery de cette manière : Et vous avez ensuite voulu appelé dans votre fichier twig jQuery de

jQuery, Webpack et Symfony | Appeler jQuery dans vos fichiers twig Lire la suite »