How to Create a Bundle in Symfony

Bhavin Nakrani on 2023-10-17

In this step-by-step guide, you’ll discover that creating a Bundle for a Symfony application may be easier than you think.

Bundles in Symfony are akin to plugins found in other software, but they offer even greater versatility. Symfony’s core features are realized through bundles, such as DoctrineBundle, LexikJWTAuthenticationBundle, WebpackEncoreBundle, and more.

Let’s begin by taking a specific example of how to create a Bundle.

PasswordStrengthBundle

We will create the PasswordStrengthBundle, which is introduced in Symfony 6.3 but does not exist in earlier versions. This bundle is dedicated to Symfony and is designed for handling constraints.

Basic features

This bundle encompasses a range of validations, including minimum length requirements, the inclusion of alphabetic and/or numeric characters, the usage of mixed-case characters, and the incorporation of ‘special’ characters.

Folder structure

It depends on the feature of the Bundle. In our case, it relates to the folder structure.