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