KNP Labs

KNP Labs “We offer Quality Development services for your Symfony project.” We only hire and train passionate developers: be sure that they will care about your code!

The KNP Labs agency was started in 2009 by developers for entrepreneurs, CTOs and communication agencies all over the world. Our goal is to help you make your Symfony2 project a success thanks to our experience with it − both in commercial and open-source projects.

Our bundle's object wrapper doesn’t play nicely with Twig. We'll fix that - but first, let’s write a unit test to be sur...
26/09/2025

Our bundle's object wrapper doesn’t play nicely with Twig. We'll fix that - but first, let’s write a unit test to be sure it works correctly outside of Twig. We'll all sleep better with code that's properly tested!

We have a little hiccup when using our "TranslatedObject" in Twig. Here's what's going on

Our bundle is all about translating objects. How are we going to do this? Well, let's look at some options and implement...
24/09/2025

Our bundle is all about translating objects. How are we going to do this? Well, let's look at some options and implement a solution! Booyah!

Alright, so now we have a way to store our translations. Let's dive into how we can make use of them

Our bundle’s configuration is validated and ready to go, woohoo! Now, let’s put that config to work by injecting it into...
22/09/2025

Our bundle’s configuration is validated and ready to go, woohoo! Now, let’s put that config to work by injecting it into one of our bundle’s services so it can actually do something useful.

In our bundle, we've defined and validated the "translation_class" configuration option. In our app, we've configured it as "App\Entity\Translation"

Bundle configuration nodes can have validation rules. These help make sure the user’s value is what you expect - no ‘che...
19/09/2025

Bundle configuration nodes can have validation rules. These help make sure the user’s value is what you expect - no ‘cheeseburger’ when you wanted a number. Let’s look at some out of the box rules + create a custom rule!

Alight, we have this "translation_class" configuration option in our bundle. It needs some validation: first, it should be required, second, it should be a non-empty string, and third, it should be a valid class that extends our bundle's "Translation" class

Our bundle needs to know about our entity class. Sounds like the perfect job for bundle configuration! We'll define a "n...
18/09/2025

Our bundle needs to know about our entity class. Sounds like the perfect job for bundle configuration! We'll define a "node" and add a description + example to help our future users! Go team!

We need to let our bundle know about our shiny new "Translation" entity. Bundle configuration is the best way to do this

Our bundle has a Doctrine "mapped superclass" successfully registered. Now we need create the "real" entity in our app, ...
17/09/2025

Our bundle has a Doctrine "mapped superclass" successfully registered. Now we need create the "real" entity in our app, let's go!

Our bundle has an abstract "Translation" *mapped superclass* and is registered with Doctrine. Time to create the *real* "Translation" entity in our app

Our bundle now has an object to be used as a Doctrine entity ✅.  Our next task is to provide mapping information and let...
16/09/2025

Our bundle now has an object to be used as a Doctrine entity ✅. Our next task is to provide mapping information and let Symfony + Doctrine know about it.

We created the abstract "Translation" class in our bundle. Now, we need to tell Doctrine about it so we can extend and use it in our app as a *real* entity

Bundles can totally provide Doctrine entities... but there are some tricks. Let's discuss the entity we need, create the...
15/09/2025

Bundles can totally provide Doctrine entities... but there are some tricks. Let's discuss the entity we need, create the class, see some bundle-specific considerations and have a great time along the way 😎

Our bundle needs a way to *store* the object translations. Since we're translating Doctrine entities from the database, we know a database is in use

In bundles, services need to be wired manually - just like Symfony apps in 2011! But don’t worry: it’s simpler now. Whil...
12/09/2025

In bundles, services need to be wired manually - just like Symfony apps in 2011! But don’t worry: it’s simpler now. While we can’t use autowiring inside the bundle, we can make our bundle’s services autowireable. Nice!

We created the class we want to use as a service in our bundle, but when we try to inject it, we get this "cannot autowire argument..." error. In your end apps, you might be used to this *just working*

Our bundle is kinda boring still. Let's spice it up with it's first service class!
11/09/2025

Our bundle is kinda boring still. Let's spice it up with it's first service class!

Ok, our bundle is installed and ready to roll. Time to add some functionality by adding our first service class

Even if you're developing bundles locally, you'll still need to install them with composer. Installation is a little dif...
10/09/2025

Even if you're developing bundles locally, you'll still need to install them with composer. Installation is a little different... but in a good way! We'll even stumble upon a hidden Symfony Flex feature 🌟

We have a bundle "package" and bundle class, and even though it lives within our app, we still need to "install" it. This is handled with Composer like normal but the method is a little different

A bundle requires just one thing: a bundle class - the nerve center of your bundle. Let's create one, right after we fix...
09/09/2025

A bundle requires just one thing: a bundle class - the nerve center of your bundle. Let's create one, right after we fix a little quirk when working with multiple namespaces in the same project.

We have a home for our bundle within our app. And, we've set up it's "composer

Adresse

8q Rue Emile Péhant
Nantes
44000

Notifications

Soyez le premier à savoir et laissez-nous vous envoyer un courriel lorsque KNP Labs publie des nouvelles et des promotions. Votre adresse e-mail ne sera pas utilisée à d'autres fins, et vous pouvez vous désabonner à tout moment.

Souligner

Partager