Skip to content

Commit 14cfc89

Browse files
committed
minor #13778 Update documentation for removal of config/bootstrap.php (javiereguiluz)
This PR was merged into the 5.1 branch. Discussion ---------- Update documentation for removal of config/bootstrap.php Fixes #13759. Commits ------- a711d03 Update documentation for removal of config/bootstrap.php
2 parents 3f51b96 + a711d03 commit 14cfc89

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

configuration/dot-env-changes.rst

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,12 @@ If you created your application after November 15th 2018, you don't need to make
4545
any changes! Otherwise, here is the list of changes you'll need to make - these
4646
changes can be made to any Symfony 3.4 or higher app:
4747

48-
#. Create a new `config/bootstrap.php`_ file in your project. This file loads Composer's
49-
autoloader and loads all the ``.env`` files as needed (note: in an earlier recipe,
50-
this file was called ``src/.bootstrap.php``; if you are upgrading from Symfony 3.3
51-
or 4.1, use the `3.3/config/bootstrap.php`_ file instead).
48+
#. Update your ``public/index.php`` file to add the code of the `public/index.php`_
49+
file provided by Symfony. If you've customized this file, make sure to keep
50+
those changes (but add the rest of the changes made by Symfony).
5251

53-
#. Update your `public/index.php`_ (`index.php diff`_) file to load the new ``config/bootstrap.php``
54-
file. If you've customized this file, make sure to keep those changes (but use
55-
the rest of the changes).
56-
57-
#. Update your `bin/console`_ file to load the new ``config/bootstrap.php`` file.
52+
#. Update your ``bin/console`` file to add the code of the `bin/console`_ file
53+
provided by Symfony.
5854

5955
#. Update ``.gitignore``:
6056

@@ -86,14 +82,11 @@ changes can be made to any Symfony 3.4 or higher app:
8682
You can also update the `comment on the top of .env`_ to reflect the new changes.
8783

8884
#. If you're using PHPUnit, you will also need to `create a new .env.test`_ file
89-
and update your `phpunit.xml.dist file`_ so it loads the ``config/bootstrap.php``
85+
and update your `phpunit.xml.dist file`_ so it loads the ``tests/bootstrap.php``
9086
file.
9187

92-
.. _`config/bootstrap.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/config/bootstrap.php
93-
.. _`3.3/config/bootstrap.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/config/bootstrap.php
94-
.. _`public/index.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/public/index.php
95-
.. _`index.php diff`: https://github.com/symfony/recipes/compare/8a4e5555e30d5dff64275e2788a901f31a214e79...86e2b6795c455f026e5ab0cba2aff2c7a18511f7#diff-7d73eabd1e5eb7d969ddf9a7ce94f954
96-
.. _`bin/console`: https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console
88+
.. _`public/index.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/5.1/public/index.php
89+
.. _`bin/console`: https://github.com/symfony/recipes/blob/master/symfony/console/5.1/bin/console
9790
.. _`comment on the top of .env`: https://github.com/symfony/recipes/blob/master/symfony/flex/1.0/.env
9891
.. _`create a new .env.test`: https://github.com/symfony/recipes/blob/master/symfony/phpunit-bridge/3.3/.env.test
9992
.. _`phpunit.xml.dist file`: https://github.com/symfony/recipes/blob/master/symfony/phpunit-bridge/3.3/phpunit.xml.dist

migration.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ could look something like this::
241241
use Symfony\Component\Debug\Debug;
242242
use Symfony\Component\HttpFoundation\Request;
243243

244-
require dirname(__DIR__).'/config/bootstrap.php';
244+
require dirname(__DIR__).'/vendor/autoload.php';
245+
246+
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
245247

246248
/*
247249
* The kernel will always be available globally, allowing you to

testing/bootstrap.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ running those tests. For example, if you're running a functional test and
66
have introduced a new translation resource, then you will need to clear your
77
cache before running those tests.
88

9-
To do this, first add a file that executes your bootstrap work::
9+
Symfony already created the following ``tests/bootstrap.php`` file when installing
10+
the package to work with tests. If you don't have this file, create it::
1011

1112
// tests/bootstrap.php
12-
if (isset($_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'])) {
13-
// executes the "php bin/console cache:clear" command
14-
passthru(sprintf(
15-
'APP_ENV=%s php "%s/../bin/console" cache:clear --no-warmup',
16-
$_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'],
17-
__DIR__
18-
));
19-
}
13+
use Symfony\Component\Dotenv\Dotenv;
14+
15+
require dirname(__DIR__).'/vendor/autoload.php';
2016

21-
require __DIR__.'/../config/bootstrap.php';
17+
if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
18+
require dirname(__DIR__).'/config/bootstrap.php';
19+
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
20+
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
21+
}
2222

23-
Then, configure ``phpunit.xml.dist`` to execute this ``bootstrap.php`` file
23+
Then, check that your ``phpunit.xml.dist`` file runs this ``bootstrap.php`` file
2424
before running the tests:
2525

2626
.. code-block:: xml

0 commit comments

Comments
 (0)