Pages

Tuesday, May 28, 2013

Creating a bundle in Symfony2

Overview
    Learning with a sample project is a best way to learn a project. Here I am going to create a blog system. Here is my ERD. actually this is not mine, i have downloaded .mwb file from http://www.jarrodoberto.com and littlebit modification to it. thanks jarrod.


I have divided these into two separate section, user and blog. So i have to create to bundles. here i am going to crate "User" bundle.
  
Symfony2 command line tool provided a good support to developers. they don't need to create all file manual. just have to execute few commands in the terminal and will get a bundle easily.

open the terminal and change your directory to the project folder, then execute fallowing command

$ php app/console generate:bundle

then it will ask parameter one by one. in this time I create a bundle called "Document". the bundle will automatically be created inside the "src" folder.
and the bundle must be located inside the "Acme" folder and it's name must be ended with suffix "Bundle". at this time command line tool ask  namespace value, here it is "Acme/UserBundle". then it will ask as fallows

Bundle namespace: Acme/UserBundle
Bundle name [Acme
UserBundle]:
Target directory [/var/www/kanasblog/src]:
Configuration format (yml, xml, php, or annotation): yml
Do you want to generate the whole directory structure [no]? Yes
Do you confirm generation [yes]? Yes
Confirm automatic update of your Kernel [yes]?
Confirm automatic update of the Routing [yes]?
 

default values has shown inside the squire brackets.

thats it.. the bundle has generated now. to check that open the fallowing url in your browser

 http://localhost:8000/hello/kanasblog

it should display "kanasblog" in the browser..


No comments:

Post a Comment