Skip to content

Commit 626327b

Browse files
committed
minor #11930 [Bundles] Documented the getPublicDir() method (javiereguiluz)
This PR was squashed before being merged into the 4.4 branch (closes #11930). Discussion ---------- [Bundles] Documented the getPublicDir() method Fixes #11927. Commits ------- 1a08208 [Bundles] Documented the getPublicDir() method
2 parents 37f09a4 + 1a08208 commit 626327b

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

bundles.rst

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ Bundle Directory Structure
8585

8686
The directory structure of a bundle is meant to help to keep code consistent
8787
between all Symfony bundles. It follows a set of conventions, but is flexible
88-
to be adjusted if needed. Take a look at AcmeDemoBundle, as it contains some
89-
of the most common elements of a bundle:
88+
to be adjusted if needed:
9089

9190
``Controller/``
9291
Contains the controllers of the bundle (e.g. ``RandomController.php``).
@@ -118,6 +117,35 @@ database, create and validate forms, create translations for your application,
118117
write tests and much more. Each of these has their own place and role within
119118
the bundle.
120119

120+
Overridding the Bundle Directory Structure
121+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122+
123+
Some of the bundle directories are conventions that can be overridden if needed.
124+
For example, the **public directory**, which by default is located at
125+
``<your-bundle>/Resources/public/``, can be changed by defining the
126+
``getPublicDir()`` method in the bundle class::
127+
128+
// src/Acme/TestBundle/AcmeTestBundle.php
129+
namespace App\Acme\TestBundle;
130+
131+
use Symfony\Component\HttpKernel\Bundle\Bundle;
132+
133+
class AcmeTestBundle extends Bundle
134+
{
135+
// ...
136+
137+
// the returned value must be relative to the bundle root directory
138+
// (public dir is now <your-bundle>/public/ instead of <your-bundle>/Resources/public/)
139+
public function getPublicDir(): string
140+
{
141+
return 'public/';
142+
}
143+
}
144+
145+
.. versionadded:: 4.4
146+
147+
The ``getPublicDir()`` method was introduced in Symfony 4.4.
148+
121149
Learn more
122150
----------
123151

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy