@@ -22,13 +22,15 @@ file::
22
22
return [
23
23
// 'all' means that the bundle is enabled for any Symfony environment
24
24
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
25
- Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
26
- Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
27
- Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
28
- Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
29
- Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
25
+ // ...
26
+
27
+ // this bundle is enabled only in 'dev'
28
+ Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
29
+ // ...
30
+
30
31
// this bundle is enabled only in 'dev' and 'test', so you can't use it in 'prod'
31
32
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
33
+ // ...
32
34
];
33
35
34
36
.. tip ::
@@ -41,18 +43,18 @@ Creating a Bundle
41
43
-----------------
42
44
43
45
This section creates and enables a new bundle to show there are only a few steps required.
44
- The new bundle is called AcmeTestBundle , where the ``Acme `` portion is an example
46
+ The new bundle is called AcmeBlogBundle , where the ``Acme `` portion is an example
45
47
name that should be replaced by some "vendor" name that represents you or your
46
- organization (e.g. AbcTestBundle for some company named ``Abc ``).
48
+ organization (e.g. AbcBlogBundle for some company named ``Abc ``).
47
49
48
- Start by creating a new class called ``AcmeTestBundle ``::
50
+ Start by creating a new class called ``AcmeBlogBundle ``::
49
51
50
- // src/AcmeTestBundle .php
51
- namespace Acme\TestBundle ;
52
+ // src/AcmeBlogBundle .php
53
+ namespace Acme\BlogBundle ;
52
54
53
55
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
54
56
55
- class AcmeTestBundle extends AbstractBundle
57
+ class AcmeBlogBundle extends AbstractBundle
56
58
{
57
59
}
58
60
@@ -68,10 +70,10 @@ Start by creating a new class called ``AcmeTestBundle``::
68
70
69
71
.. tip ::
70
72
71
- The name AcmeTestBundle follows the standard
73
+ The name AcmeBlogBundle follows the standard
72
74
:ref: `Bundle naming conventions <bundles-naming-conventions >`. You could
73
- also choose to shorten the name of the bundle to simply TestBundle by naming
74
- this class TestBundle (and naming the file ``TestBundle .php ``).
75
+ also choose to shorten the name of the bundle to simply BlogBundle by naming
76
+ this class BlogBundle (and naming the file ``BlogBundle .php ``).
75
77
76
78
This empty class is the only piece you need to create the new bundle. Though
77
79
commonly empty, this class is powerful and can be used to customize the behavior
@@ -80,10 +82,10 @@ of the bundle. Now that you've created the bundle, enable it::
80
82
// config/bundles.php
81
83
return [
82
84
// ...
83
- Acme\TestBundle\AcmeTestBundle ::class => ['all' => true],
85
+ Acme\BlogBundle\AcmeBlogBundle ::class => ['all' => true],
84
86
];
85
87
86
- And while it doesn't do anything yet, AcmeTestBundle is now ready to be used.
88
+ And while it doesn't do anything yet, AcmeBlogBundle is now ready to be used.
87
89
88
90
Bundle Directory Structure
89
91
--------------------------
@@ -92,31 +94,31 @@ The directory structure of a bundle is meant to help to keep code consistent
92
94
between all Symfony bundles. It follows a set of conventions, but is flexible
93
95
to be adjusted if needed:
94
96
95
- ``src/ ``
96
- Contains all PHP classes related to the bundle logic (e.g. ``Controller/RandomController.php ``).
97
+ ``assets/ ``
98
+ Contains the web asset sources like JavaScript and TypeScript files, CSS and
99
+ Sass files, but also images and other assets related to the bundle that are
100
+ not in ``public/ `` (e.g. Stimulus controllers).
97
101
98
102
``config/ ``
99
- Houses configuration, including routing configuration (e.g. ``routing.yaml ``).
100
-
101
- ``templates/ ``
102
- Holds templates organized by controller name (e.g. ``random/index.html.twig ``).
103
-
104
- ``translations/ ``
105
- Holds translations organized by domain and locale (e.g. ``AcmeTestBundle.en.xlf ``).
103
+ Houses configuration, including routing configuration (e.g. ``routes.php ``).
106
104
107
105
``public/ ``
108
106
Contains web assets (images, compiled CSS and JavaScript files, etc.) and is
109
107
copied or symbolically linked into the project ``public/ `` directory via the
110
108
``assets:install `` console command.
111
109
112
- ``assets/ ``
113
- Contains the web asset sources (JavaScript and TypeScript files, CSS and Sass
114
- files, etc.), images and other assets related to the bundle that are not in
115
- ``public/ `` (e.g. Stimulus controllers)
110
+ ``src/ ``
111
+ Contains all PHP classes related to the bundle logic (e.g. ``Controller/CategoryController.php ``).
112
+
113
+ ``templates/ ``
114
+ Holds templates organized by controller name (e.g. ``category/show.html.twig ``).
116
115
117
116
``tests/ ``
118
117
Holds all tests for the bundle.
119
118
119
+ ``translations/ ``
120
+ Holds translations organized by domain and locale (e.g. ``AcmeBlogBundle.en.xlf ``).
121
+
120
122
.. caution ::
121
123
122
124
The recommended bundle structure was changed in Symfony 5, read the
@@ -127,7 +129,7 @@ to be adjusted if needed:
127
129
new structure. Override the ``Bundle::getPath() `` method to change to
128
130
the old structure::
129
131
130
- class AcmeTestBundle extends AbstractBundle
132
+ class AcmeBlogBundle extends AbstractBundle
131
133
{
132
134
public function getPath(): string
133
135
{
@@ -146,12 +148,12 @@ to be adjusted if needed:
146
148
{
147
149
"autoload" : {
148
150
"psr-4" : {
149
- "Acme\\ TestBundle \\ " : " src/"
151
+ "Acme\\ BlogBundle \\ " : " src/"
150
152
}
151
153
},
152
154
"autoload-dev" : {
153
155
"psr-4" : {
154
- "Acme\\ TestBundle \\ Tests\\ " : " tests/"
156
+ "Acme\\ BlogBundle \\ Tests\\ " : " tests/"
155
157
}
156
158
}
157
159
}
0 commit comments