Problem/Motivation

#3583505: Use Symfony PhpDumper instead of a serialized array container structure is discussing moving the runtime container from our custom array structure to PHP.

The bootstrap container is a very small container (six services) that is used to retrieve and start the runtime container.

Currently this is defined as a static array that is parsed and services are constructed from there. To save parsing this on every request we could just hardcode this as a simple PHP container implementation that will live in opcache.

Steps to reproduce

Proposed resolution

Convert DrupalKernel::$defaultBootstrapContainerDefinition to a PHP class.
Retain the ability for users to override this container in settings.php.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3585294

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review

longwave’s picture

I guess we could remove the bootstrap container class entirely:

    if ($containerDefinition = Settings::get('bootstrap_container_definition')) {
      $bootstrapContainer = new $this->bootstrapContainerClass($containerDefinition);
      $this->containerCache = $bootstrapContainer->get('cache.container');
    }
    else {
      $db = Database::getConnection();
      $this->containerCache = new DatabaseBackend(
        $db,
        new DatabaseCacheTagsChecksum($db),
        'container',
        new PhpSerialize(),
        new Time(new RequestStack()),
        DatabaseBackend::MAXIMUM_NONE,
      );
    }
nicxvan’s picture

Not quite exactly related, but it seems in similar space as #3576593: Create pre-bootstrap extension mechanism

longwave’s picture

Status: Needs review » Needs work

The types come from upstream, I think we should leave them alone - we could narrow them but are we trapping ourselves if we do?

If we extract the service creation into its own method and allow the class name to be set in settings.php, then this would be more extensible by downstream users such as Redis.

longwave’s picture

Status: Needs work » Postponed

Now postponing on #3583505: Use Symfony PhpDumper instead of a serialized array container structure as we are adding to the bootstrap container over there.