Creating and deleting bundles in Symfony (Lesson 4)

So, after studying the materials 1, 2, 3, it's time to start developing your first Symfony application =). So, as you already know, everything in Symfony is a bundle. And, as you remember, the place for bundles is the src/ directory. To generate a bundle, simply execute the commands:

cd /path_to_project
php app/console generate:bundle
and then follow the installer instructions.

You will be asked to specify the namespace and the name for the bundle.

The namespace must necessarily contain "Bundle" at the end. For example, a correct namespace looks like this: Acme/HelloBundle. Acme is your name, your company's name, or something similar, and after that, HelloBundle is what pertains to the bundle. After that, you need to specify the name. The name should be made from the namespace: AcmeHelloBundle - it's very simple =).

You will also be asked to select a directory, a configuration format, and generate a directory structure. The generator can also immediately include the bundle in the application kernel and generate a basic routing. I advise you to allow these things to be done automatically - it will greatly simplify your life, especially if you are just learning.

Unfortunately, for bundle removal you need to do some additional steps:

  1. First, delete the /src/Name/Bundle directory
  2. Edit /app/config/routing.yml - remove references to the bundle.
  3. Remove the bundle from /app/Resources/App.Kernel.php
  4. Clear cache:
./app/console cache:clear