Integrate dynamic Propel configuration

Edit on GitHub

Previously, it was always necessary to run the vendor/bin/console propel:config:convert command for Propel to fetch database configuration and generate the propel.json file where it was stored.

If the configuration changed, it was necessary to run the command again for Propel to re-generate the file with the new database configuration.

To avoid running the command each time the configuration changes, we introduce a dynamic propel configuration that is:

  • real-time available;
  • fetched from the current environment configuration without running any commands.

Integration

Prerequisites

Ensure that the related features are installed:

NAME VERSION REQUIRED SUB-FEATURE
Spryker Core Feature

1) Install the required modules

Install the required modules using Composer:

composer require spryker/propel:"^3.10.0" spryker/propel-orm:"^1.9.0" --update-with-dependencies
Verification

Make sure that the following modules have been installed:

MODULE EXPECTED DIRECTORY
Propel vendor/spryker/propel
PropelOrm vendor/spryker/propel-orm

2) Set up behavior

Clean up install recipes

Delete the propel:config:convert command from all install recipes ( config/install/developing.yml, config/install/testing.yml, etc.):

propel-config:
    command: "vendor/bin/console propel:config:convert"

Spryker\Zed\Propel\Communication\Console\ConvertConfigConsole is deprecated.

Delete all the src/Orm/Propel/*/Config/*/propel.json files - they are not needed from now on.

Supporting native Propel commands

To run Propel commands directly, set up a runtime configuration by creating the file:

src/Orm/Propel/propel.php

<?php

use Spryker\Shared\Config\Application\Environment;
use Spryker\Shared\Config\Config;
use Spryker\Shared\Propel\PropelConstants;

define('APPLICATION', 'ZED');
define('APPLICATION_ROOT_DIR', dirname(__DIR__, 3));

require_once APPLICATION_ROOT_DIR . '/vendor/autoload.php';

Environment::initialize();

$config = Config::getInstance();
$config::init(APPLICATION_ENV);

return [
    'propel' => $config::get(PropelConstants::PROPEL)
];

Run native Propel commands with the following argument:

$ propel migration:down --config-dir src/Orm/Propel/