I never used a php framework and thought i give it a try. I installed symfony2 but I’m a bit confused as to what the standard file structure should be when a new bundle is created. based on the symfony documentation/ tutorials i seen, there should be many folders under src->appbundler but the bundle i created only has 2 folders.
The two folders under Src/appBundle:
1 controllers folder
2. Test folder
3 one file named appbundle
the documentations/tutorials present a different file structure which includes many folders:
Did I not create the bundle correctly???
os: win 7
Strictly speaking, the AppBundle.php file is all you need to create a bundle. Even the Controller and Tests directories are optional.
If you use
and answer yes to:
Do you want to generate the whole directory structure [no]? yes
Then you will also get DependencyInjection and Resources directories.
But the bottom line is that all the directories are optional. You just create as needed. For example, if your bundle has Doctrine entities then create an Entity directory and store them there.
Thanks for the reply and for the clarification.
im on windows 7 using xampp and to create a new bundle i run the following command php symfony.phar new myproject is there a way to create the bundle with those directories using the above command or even run the command you suggested so the directories are created to stay consistent with the tutorials online?
i tried running the command in the windows shell and didnt work?
thanks for your help
Nope. Again, just create the directories as needed. Symfony 2 has very few directory name requirements. This is in contrast to many other more opinionated frameworks. So follow your tutorial.
There is also a Symfony Best Practices guide (http://symfony.com/doc/2.7/best_practices/index.html) which you should also become familiar with. It’s fairly new so you will see many tutorials and articles violate these practices. That’s okay as long as you understand the best practices and use them in your own code where it makes sense.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.