Diary of problems and solutions related to web programming, database development and related technologies and platforms.

Creating and deleting bundle using Symfony2

Creating Bundle

Open up the command line Git Bash

Go to the project folder
$ cd C:/wamp/www/Symfony2Project

Run the generate bundle command
$php app/console generate:bundle

Bundle namespace: Suresh/Bundle/CrudBundle
Press Enter to confirm namespace
Press Enter again to confirm the target directory src.
Configuration format: yml
Generate the whole directory structure? yes
Do you confirm generation? Press enter to confirm.
Update kernel? Press enter for yes
Update routing? Press enter for yes

Now the bundle has been created and code has generated. This will also create a DefaultController.php inside Controller.

Running web server
$ php app/console server:run

To access the page, see the routing.yml inside Suresh/Bundle/CrudBundle/Resources/config folders. You will see the routing style as /hello/{name}

Open a browser and run the page like this way:

http://localhost:8000/hello/John

Deleting Bundle

To delete bundle, follow these steps
- Delete the folder "Suresh" located inside src folder.
- Open AppKernel.php located inside app folder. Inside registerBundles() function delete the following line.
new Suresh\Bundle\CrudBundle\SureshCrudBundle(),
- Open routing.yml located inside app/config and delete the following lines.
suresh_crud:
    resource: "@SureshCrudBundle/Resources/config/routing.yml"
    prefix:   /

This will help you deleting the bundle completely.

No comments :

Post a Comment