@@ -45,15 +45,13 @@ bundle class name must follow these simple rules:
45
45
46
46
Here are some valid bundle namespaces and class names:
47
47
48
- +-----------------------------------+--------------------------+
49
- | Namespace | Bundle Class Name |
50
- +===================================+==========================+
51
- | ``Acme\Bundle\BlogBundle `` | ``AcmeBlogBundle `` |
52
- +-----------------------------------+--------------------------+
53
- | ``Acme\Bundle\Social\BlogBundle `` | ``AcmeSocialBlogBundle `` |
54
- +-----------------------------------+--------------------------+
55
- | ``Acme\BlogBundle `` | ``AcmeBlogBundle `` |
56
- +-----------------------------------+--------------------------+
48
+ ================================= ========================
49
+ Namespace Bundle Class Name
50
+ ================================= ========================
51
+ ``Acme\Bundle\BlogBundle `` ``AcmeBlogBundle ``
52
+ ``Acme\Bundle\Social\BlogBundle `` ``AcmeSocialBlogBundle ``
53
+ ``Acme\BlogBundle `` ``AcmeBlogBundle ``
54
+ ================================= ========================
57
55
58
56
By convention, the ``getName() `` method of the bundle class should return the
59
57
class name.
@@ -83,22 +81,19 @@ The basic directory structure of a HelloBundle must read as follows:
83
81
84
82
.. code-block :: text
85
83
86
- XXX/...
87
- HelloBundle/
88
- HelloBundle.php
89
- Controller/
90
- Resources/
91
- meta/
92
- LICENSE
93
- config/
94
- doc/
95
- index.rst
96
- translations/
97
- views/
98
- public/
99
- Tests/
100
-
101
- The ``XXX `` directory(ies) reflects the namespace structure of the bundle.
84
+ HelloBundle/
85
+ ├─ HelloBundle.php
86
+ ├─ Controller/
87
+ ├─ Resources/
88
+ │ ├─ meta/
89
+ │ │ └─ LICENSE
90
+ │ ├─ config/
91
+ │ ├─ doc/
92
+ │ │ └─ index.rst
93
+ │ ├─ translations/
94
+ │ ├─ views/
95
+ │ └─ public/
96
+ └─ Tests/
102
97
103
98
The following files are mandatory:
104
99
@@ -122,46 +117,38 @@ files are going to be part of the repository.
122
117
123
118
The following classes and files have specific emplacements:
124
119
125
- +------------------------------+-----------------------------+
126
- | Type | Directory |
127
- +==============================+=============================+
128
- | Commands | ``Command/ `` |
129
- +------------------------------+-----------------------------+
130
- | Controllers | ``Controller/ `` |
131
- +------------------------------+-----------------------------+
132
- | Service Container Extensions | ``DependencyInjection/ `` |
133
- +------------------------------+-----------------------------+
134
- | Event Listeners | ``EventListener/ `` |
135
- +------------------------------+-----------------------------+
136
- | Configuration | ``Resources/config/ `` |
137
- +------------------------------+-----------------------------+
138
- | Web Resources | ``Resources/public/ `` |
139
- +------------------------------+-----------------------------+
140
- | Translation files | ``Resources/translations/ `` |
141
- +------------------------------+-----------------------------+
142
- | Templates | ``Resources/views/ `` |
143
- +------------------------------+-----------------------------+
144
- | Unit and Functional Tests | ``Tests/ `` |
145
- +------------------------------+-----------------------------+
120
+ ============================ ===========================
121
+ Type Directory
122
+ ============================ ===========================
123
+ Commands ``Command/ ``
124
+ Controllers ``Controller/ ``
125
+ Service Container Extensions ``DependencyInjection/ ``
126
+ Event Listeners ``EventListener/ ``
127
+ Configuration ``Resources/config/ ``
128
+ Web Resources ``Resources/public/ ``
129
+ Translation files ``Resources/translations/ ``
130
+ Templates ``Resources/views/ ``
131
+ Tests ``Tests/ ``
132
+ ============================ ===========================
146
133
147
134
.. note ::
148
135
149
136
When building a reusable bundle, model classes should be placed in the
150
- ``Model `` namespace. See :doc: `/cookbook/doctrine/mapping_model_classes ` for
137
+ ``Model `` namespace. See :doc: `/cookbook/doctrine/mapping_model_classes ` on
151
138
how to handle the mapping with a compiler pass.
152
139
153
140
Classes
154
141
-------
155
142
156
143
The bundle directory structure is used as the namespace hierarchy. For
157
144
instance, a ``HelloController `` controller is stored in
158
- ``Bundle/ HelloBundle/Controller/HelloController.php `` and the fully qualified
159
- class name is ``Bundle\ HelloBundle\Controller\HelloController ``.
145
+ ``HelloBundle/Controller/HelloController.php `` and the fully qualified
146
+ class name is ``HelloBundle\Controller\HelloController ``.
160
147
161
148
All classes and files must follow the Symfony coding :doc: `standards </contributing/code/standards >`.
162
149
163
150
Some classes should be seen as facades and should be as short as possible, like
164
- Commands, Helpers, Listeners, and Controllers.
151
+ Commands, Helpers, Listeners and Controllers.
165
152
166
153
Classes that connect to the event dispatcher should be suffixed with
167
154
``Listener ``.
@@ -174,7 +161,7 @@ Vendors
174
161
A bundle must not embed third-party PHP libraries. It should rely on the
175
162
standard Symfony autoloading instead.
176
163
177
- A bundle should not embed third-party libraries written in JavaScript, CSS, or
164
+ A bundle should not embed third-party libraries written in JavaScript, CSS or
178
165
any other language.
179
166
180
167
Tests
@@ -190,6 +177,7 @@ the ``Tests/`` directory. Tests should follow the following principles:
190
177
* The tests should cover at least 95% of the code base.
191
178
192
179
.. note ::
180
+
193
181
A test suite must not contain ``AllTests.php `` scripts, but must rely on the
194
182
existence of a ``phpunit.xml.dist `` file.
195
183
@@ -369,12 +357,6 @@ The end user can provide values in any configuration file:
369
357
// app/config/config.php
370
358
$container->setParameter('acme_hello.email.from', 'fabien@example.com');
371
359
372
- .. code-block :: ini
373
-
374
- ; app/config/config.ini
375
- [parameters]
376
- acme_hello.email.from = fabien@example.com
377
-
378
360
Retrieve the configuration parameters in your code from the container::
379
361
380
362
$container->getParameter('acme_hello.email.from');
0 commit comments