Symfony

Custom Bundles

Bundle creation, extension configuration, compiler passes, reusable bundles, best practices

20 pertanyaan wawancaraยท
Senior
1

Which class must the main bundle class extend in Symfony?

Jawaban

The main bundle class in Symfony must extend AbstractBundle (Symfony 6.1+) or Bundle. AbstractBundle is recommended as it simplifies configuration and allows defining configuration directly in the bundle class via the configure() method. Bundle remains available for backward compatibility but AbstractBundle offers a more modern API.

2

What is the role of the Extension class in a Symfony bundle?

Jawaban

The Extension class (extending ConfigurableExtension or Extension) is responsible for loading the bundle configuration and registering services in the container. It reads the bundle's configuration files, processes application parameters, and configures services via the ContainerBuilder. It implements the load() method which is called during container compilation.

3

What is the naming convention for the main class of a bundle named AcmePaymentBundle?

Jawaban

By Symfony convention, the main bundle class must have the same name as the bundle. For AcmePaymentBundle, the main class will be AcmePaymentBundle and must be in the corresponding namespace, typically Acme\PaymentBundle. The file will therefore be AcmePaymentBundle.php in the bundle's src/ folder.

4

What is a Compiler Pass in Symfony and when should it be used?

5

How to define semantic configuration for a bundle with parameter validation?

+17 pertanyaan wawancara

Kuasai Symfony untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis