Skip to content

Update documentation for removal of config/bootstrap.php #13778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions configuration/dot-env-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ If you created your application after November 15th 2018, you don't need to make
any changes! Otherwise, here is the list of changes you'll need to make - these
changes can be made to any Symfony 3.4 or higher app:

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

#. Update your `public/index.php`_ (`index.php diff`_) file to load the new ``config/bootstrap.php``
file. If you've customized this file, make sure to keep those changes (but use
the rest of the changes).

#. Update your `bin/console`_ file to load the new ``config/bootstrap.php`` file.
#. Update your ``bin/console`` file to add the code of the `bin/console`_ file
provided by Symfony.

#. Update ``.gitignore``:

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

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

.. _`config/bootstrap.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/config/bootstrap.php
.. _`3.3/config/bootstrap.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/config/bootstrap.php
.. _`public/index.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/public/index.php
.. _`index.php diff`: https://github.com/symfony/recipes/compare/8a4e5555e30d5dff64275e2788a901f31a214e79...86e2b6795c455f026e5ab0cba2aff2c7a18511f7#diff-7d73eabd1e5eb7d969ddf9a7ce94f954
.. _`bin/console`: https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console
.. _`public/index.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/5.1/public/index.php
.. _`bin/console`: https://github.com/symfony/recipes/blob/master/symfony/console/5.1/bin/console
.. _`comment on the top of .env`: https://github.com/symfony/recipes/blob/master/symfony/flex/1.0/.env
.. _`create a new .env.test`: https://github.com/symfony/recipes/blob/master/symfony/phpunit-bridge/3.3/.env.test
.. _`phpunit.xml.dist file`: https://github.com/symfony/recipes/blob/master/symfony/phpunit-bridge/3.3/phpunit.xml.dist
Expand Down
4 changes: 3 additions & 1 deletion migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ could look something like this::
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;

require dirname(__DIR__).'/config/bootstrap.php';
require dirname(__DIR__).'/vendor/autoload.php';

(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');

/*
* The kernel will always be available globally, allowing you to
Expand Down
22 changes: 11 additions & 11 deletions testing/bootstrap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ running those tests. For example, if you're running a functional test and
have introduced a new translation resource, then you will need to clear your
cache before running those tests.

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

// tests/bootstrap.php
if (isset($_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'])) {
// executes the "php bin/console cache:clear" command
passthru(sprintf(
'APP_ENV=%s php "%s/../bin/console" cache:clear --no-warmup',
$_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'],
__DIR__
));
}
use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__).'/vendor/autoload.php';

require __DIR__.'/../config/bootstrap.php';
if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
require dirname(__DIR__).'/config/bootstrap.php';
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}

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

.. code-block:: xml
Expand Down