User Tools

Site Tools


symfony:symfony_tutorial_notes:the_bundle_system

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
symfony:symfony_tutorial_notes:the_bundle_system [2015/09/17 01:14] – [Bundle Directory Structure] mithatsymfony:symfony_tutorial_notes:the_bundle_system [2015/09/18 04:04] (current) – [Bundle Directory Structure] mithat
Line 4: Line 4:
   * ''src/AppBundle/'' is your app.   * ''src/AppBundle/'' is your app.
   * ''vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/'' is the framework itself.   * ''vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/'' is the framework itself.
-  * [[http://symfony.com/doc/current/book/bundles.html#third-party-bundles|Third party bundles]]+  * [[http://knpbundles.com/|Third party bundles]]
   * In reality, a bundle can live anywhere as long as it can be autoloaded (via ''app/autoload.php'').   * In reality, a bundle can live anywhere as long as it can be autoloaded (via ''app/autoload.php'').
  
Line 37: Line 37:
  
 ===== Creating a Bundle ===== ===== Creating a Bundle =====
-TODO+To create ''AcmeTestBundle'' manually: 
 +  - create a ''src/Acme/TestBundle/'' directory and add ''AcmeTestBundle.php'':<file php src/Acme/TestBundle/AcmeTestBundle.php> 
 +namespace Acme\TestBundle; 
 + 
 +use Symfony\Component\HttpKernel\Bundle\Bundle; 
 + 
 +class AcmeTestBundle extends Bundle 
 +
 +
 +</file> 
 +  - enable it via the AppKernel class:<file php app/AppKernel.php> 
 +public function registerBundles() 
 +
 +    $bundles = array( 
 +        // ... 
 +        // register your bundle 
 +        new Acme\TestBundle\AcmeTestBundle(), 
 +    ); 
 +    // ... 
 + 
 +    return $bundles; 
 +
 +</file> 
 +  - Hack on controllers, etc. 
 + 
 +To create ''AcmeTestBundle'' via the command line: 
 +  * <code bash>$ php app/console generate:bundle --namespace=Acme/TestBundle</code> 
 + 
 +The bundle skeleton generates a basic controller, template, and routing resource. 
 + 
 +The ''generate:bundle'' command adds the new bundle to ''AppKernel.registerBundles()''
 + 
 +See [[http://symfony.com/doc/current/cookbook/bundles/best_practices.html#bundles-naming-conventions|Bundle Naming Conventions]].
  
 ===== Bundle Directory Structure ===== ===== Bundle Directory Structure =====
Line 51: Line 83:
          
 <WRAP center round tip 100%> <WRAP center round tip 100%>
-Note that the current best practice for the ''AppBundle'' seems to be that+Note that the current [[http://symfony.com/doc/current/best_practices/index.html|best practices]] for the ''AppBundle'' are
-  * **controllers** go in ''src/AppBundle/Controller/'' as expected. +  * **config** goes in ''app/config/'' (rather than ''src/AppBundle/Resources/config/'') 
-  * **config** goes in ''app/config'' rather than ''src/AppBundle/Resources/config/'' +  * **controllers** go in ''src/AppBundle/Controller/'' (as expected). 
-  * **views** go in ''app/Resources/views'' rather than ''src/AppBundle/Resources/views/'' +  * **views** go in ''app/Resources/views/'' (rather than ''src/AppBundle/Resources/views/'') 
-  * **assets** go in TBD+  * **assets** go in ''web/''
   * **tests** go in TBD   * **tests** go in TBD
 </WRAP> </WRAP>
  
symfony/symfony_tutorial_notes/the_bundle_system.1442452467.txt.gz · Last modified: 2015/09/17 01:14 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki