Skip to content

Commit e8b599b

Browse files
committed
Merge pull request #2067 from WouterJ/document_acme_removing
Bootstrapped article about removing bundles (especially the AcmeDemoBundle)
2 parents d1a79dc + da0cfe1 commit e8b599b

File tree

6 files changed

+115
-6
lines changed

6 files changed

+115
-6
lines changed

book/installation.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,17 @@ Beginning Development
196196
Now that you have a fully-functional Symfony2 application, you can begin
197197
development! Your distribution may contain some sample code - check the
198198
``README.md`` file included with the distribution (open it as a text file)
199-
to learn about what sample code was included with your distribution and how
200-
you can remove it later.
199+
to learn about what sample code was included with your distribution.
201200

202201
If you're new to Symfony, check out ":doc:`page_creation`", where you'll
203202
learn how to create pages, change configuration, and do everything else you'll
204203
need in your new application.
205204

205+
.. note::
206+
207+
If you want to remove the sample code from your distribution, take a look
208+
at this cookbook article: ":doc:`/cookbook/bundles/remove`"
209+
206210
Using Source Control
207211
--------------------
208212

cookbook/bundles/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ Bundles
77
best_practices
88
inheritance
99
override
10+
remove
1011
extension

cookbook/bundles/remove.rst

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
.. index::
2+
single: Bundle; Removing AcmeDemoBundle
3+
4+
How to remove the AcmeDemoBundle
5+
================================
6+
7+
The Symfony2 Standard Edition comes with a complete demo, that lives inside a
8+
bundle called ``AcmeDemoBundle``. It is a great boilerplate to refer to while
9+
starting with your project, but later on the project, it will become usefull
10+
to remove this bundle.
11+
12+
.. tip::
13+
14+
This article uses the AcmeDemoBundle as an example, you can use this
15+
article on every bundle you want to remove.
16+
17+
1. Unregister the bundle in the ``AppKernel``
18+
---------------------------------------------
19+
20+
To disconnect the bundle from the framework, you should remove the bundle from
21+
the ``Appkernel::registerBundles()`` method. The bundle is normally found in
22+
the ``$bundles`` array but the ``AcmeDemoBundle`` is only registered in a
23+
development environment and you can find him in the if statement thereafter::
24+
25+
// app/AppKernel.php
26+
27+
// ...
28+
class AppKernel extends Kernel
29+
{
30+
public function registerBundles()
31+
{
32+
$bundles = array(...);
33+
34+
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
35+
// comment or remove this line:
36+
// $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
37+
// ...
38+
}
39+
}
40+
}
41+
42+
2. Remove bundle configuration
43+
------------------------------
44+
45+
Now Symfony doesn't know about the bundle, you need to remove any
46+
configuration and routing configuration inside the ``app/config`` directory
47+
that refers to the bundle.
48+
49+
2.1 Remove bundle routing
50+
~~~~~~~~~~~~~~~~~~~~~~~~~
51+
52+
The routing for the AcmeDemoBundle can be found in
53+
``app/config/routing_dev.yml``. The routes are ``_welcome``, ``_demo_secured``
54+
and ``_demo``.
55+
56+
2.2 Remove bundle configuration
57+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58+
59+
Some bundles contains configuration in one of the ``app/config/config*.yml``
60+
files. Be sure to remove the related configuration from these files. You can
61+
quickly spot bundle configuration by looking at a ``acme_demo`` (or whatever
62+
the name of the bundle is, e.g. ``fos_user`` with the FOSUserBundle) string in
63+
the configuration files.
64+
65+
The AcmeDemoBundle doesn't have configuration. However, the bundle has set up
66+
the ``app/config/security.yml`` file. You can use it as a boilerplate for your
67+
own security, but you **can** also remove everything: It doesn't make sense to
68+
Symfony if you remove it or not.
69+
70+
3. Remove integration in other bundles
71+
--------------------------------------
72+
73+
Some bundles rely on other bundles, if you remove one of the two, the other
74+
will properbly not work. Be sure that no other bundles, third party or self
75+
made, relies on the bundle you are about to remove.
76+
77+
.. tip::
78+
79+
If a bundle relies on another bundle, it means in most of the cases that
80+
it uses some services from the other bundle. Searching for a ``acme_demo``
81+
string will help you spot them.
82+
83+
.. tip::
84+
85+
If a third party bundle relies on another bundle, you can find the bundle
86+
in the ``composer.json`` file included in the bundle directory.
87+
88+
4. Remove the bundle from the filesystem
89+
----------------------------------------
90+
91+
Now you have removed every reference to the bundle in the Symfony2
92+
application, the last thing you should do is removing the bundle from the file
93+
system. The bundle is located in the ``src/Acme/DemoBundle`` directory. You
94+
should remove this directory and you can remove the ``Acme`` directory as
95+
well, you likely won't get other bundles in that vendor.
96+
97+
.. tip::
98+
99+
If you don't know the location of a bundle, you can use the
100+
:method:`Symfony\\Bundle\\FrameworkBundle\\Bundle\\Bundle::getPath` method
101+
to get the path of the bundle::
102+
103+
echo $this->container->get('kernel')->getBundle('AcmeDemoBundle')->getPath();

cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* :doc:`/cookbook/bundles/best_practices`
1111
* :doc:`/cookbook/bundles/inheritance`
1212
* :doc:`/cookbook/bundles/override`
13+
* :doc:`/cookbook/bundles/remove`
1314
* :doc:`/cookbook/bundles/extension`
1415

1516
* :doc:`/cookbook/cache/index`

cookbook/workflow/new_project_git.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ to learn more about how to configure and develop inside your application.
116116
.. tip::
117117

118118
The Symfony2 Standard Edition comes with some example functionality. To
119-
remove the sample code, follow the instructions on the `Standard Edition Readme`_.
119+
remove the sample code, follow the instructions in the
120+
":doc:`/components/bundles/remove`" article.
120121

121122
.. _cookbook-managing-vendor-libraries:
122123

@@ -149,7 +150,6 @@ manage this is `Gitolite`_.
149150

150151
.. _`git`: http://git-scm.com/
151152
.. _`Symfony2 Standard Edition`: http://symfony.com/download
152-
.. _`Standard Edition Readme`: https://github.com/symfony/symfony-standard/blob/master/README.md
153153
.. _`git submodules`: http://git-scm.com/book/en/Git-Tools-Submodules
154154
.. _`GitHub`: https://github.com/
155155
.. _`barebones repository`: http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository

cookbook/workflow/new_project_svn.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ to learn more about how to configure and develop inside your application.
122122
.. tip::
123123

124124
The Symfony2 Standard Edition comes with some example functionality. To
125-
remove the sample code, follow the instructions on the `Standard Edition Readme`_.
125+
remove the sample code, follow the instructions in the
126+
":doc:`/components/bundles/remove`" article.
126127

127128
.. include:: _vendor_deps.rst.inc
128129

@@ -146,7 +147,6 @@ central repository to work. You then have several solutions:
146147
.. _`svn`: http://subversion.apache.org/
147148
.. _`Subversion`: http://subversion.apache.org/
148149
.. _`Symfony2 Standard Edition`: http://symfony.com/download
149-
.. _`Standard Edition Readme`: https://github.com/symfony/symfony-standard/blob/master/README.md
150150
.. _`Version Control with Subversion`: http://svnbook.red-bean.com/
151151
.. _`GitHub`: https://github.com/
152152
.. _`Google code`: http://code.google.com/hosting/

0 commit comments

Comments
 (0)