[TASK] Decouple Bootstrap and Application engaging a PSR-11 container 73/55773/51
authorBenjamin Franzke <bfr@qbus.de>
Thu, 8 Feb 2018 20:21:05 +0000 (21:21 +0100)
committerBenni Mack <benni@typo3.org>
Thu, 8 Mar 2018 21:01:18 +0000 (22:01 +0100)
commita388232d1de9ec571d2bcb10459f1fd5fefdf58b
treee05907df6304fdb2c17a85ff53253312bf05de7b
parentd6ff441c5c33a35db355b458aa5336f9432f3d9f
[TASK] Decouple Bootstrap and Application engaging a PSR-11 container

In order to avoid global state and to support full-application
subrequests (later on), bootstraping, application initialization
and application execution needs to be decoupled.
(To be able to initialize a frontend Application in backend
Application context, the frontend Application may not re-execute
bootstraping code.)

That means from now on:
 * Bootstrap is limited to stateless bootstrapping
   => setting up package manager and configuration
 * A (new) Container (PSR-11) performs class initialization
   => e.g. `new Frontend/Http/Application()`
 * Application performs execution
   => checking possible (application specific) redirects
   => offloading work to the request handler

This commit transforms Bootstrap into a (static) bootstrap utility
that returns a container (minimal, static PSR-11 implementation).
The entry-point scripts execute the bootstraper and use
the returned container to initialize and run the application.

This commit acts as a starting point for a broader PSR-11 container
support in TYPO3. We do – on purpose – use an own, very limited, anonymous
and static there is no configuration) PSR-11 implemententation for now.
This interim container implementation will be replaced by whatever
PSR-11 supporting container solution we use later on.
That keeps the necessary Bootstrap refactoring seperate from the
introduction of a full dependency injection container implementation.

All existing bootstrap methods keep working as before but the non-static
method invocation should be deprecated at some point.

typo3/cms-cli is adapted for the changed entry point script with:
https://github.com/TYPO3/cms-cli/pull/1

typo3/testing-framework is adapted in
https://github.com/TYPO3/testing-framework/pull/55

This patch brings one important behavioral change:

The install tool redirect (if essential configuration is missing) is
perfomed during application execution – after the configuration has been
loaded (falling back to failsafe mode if missing) – now. Previously the
application performed the redirect before it would call Bootstraps
configure() method. Now that the Application is decoupled from bootstrap,
the bootstrapper ensures it can always create an Application class, in
order for the application to be in charge of the decision what should
happen if essential configuration is missing.

Dependency changes:

composer require psr/container:^1.0
composer require typo3/cms-cli:^2.0
composer require typo3/testing-framework:^3.2 --dev

Change-Id: Idc59665dfcf7250a8a42b3d908a5a2376067700c
Releases: master
Resolves: #83951
Reviewed-on: https://review.typo3.org/55773
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
15 files changed:
composer.json
composer.lock
typo3/sysext/backend/Classes/Http/Application.php
typo3/sysext/backend/Resources/Private/Php/backend.php
typo3/sysext/core/Classes/Console/CommandApplication.php
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php
typo3/sysext/core/Classes/Localization/Locales.php
typo3/sysext/core/bin/typo3
typo3/sysext/core/composer.json
typo3/sysext/frontend/Classes/Http/Application.php
typo3/sysext/frontend/Resources/Private/Php/frontend.php
typo3/sysext/install/Classes/Http/Application.php
typo3/sysext/install/Classes/Http/RequestHandler.php
typo3/sysext/install/Resources/Private/Php/install.php