writeConfig example

$writer = new EnvConfigWriter(__DIR__ . '/_fixtures', $idGenerator);

        $info = new DatabaseConnectionInformation();
        $info->assign([
            'hostname' => 'localhost',
            'port' => 3306,
            'username' => 'root',
            'password' => 'root',
            'databaseName' => 'shopware',
        ]);

        $writer->writeConfig($info[
            'name' => 'test',
            'locale' => 'de-DE',
            'currency' => 'EUR',
            'additionalCurrencies' => [],
            'country' => 'DEU',
            'email' => 'test@test.com',
            'host' => 'localhost',
            'schema' => 'https',
            'basePath' => '/shop',
            'blueGreenDeployment' => true,
        ]);

        
    } catch (\Exception $e) {
        $app->render('database-configuration.php', ['error' => $e->getMessage()]);

        return;
    }

    $_SESSION['databaseConnectionInfo'] = $connectionInfo;

    try {
        /** @var ConfigWriter $configWriter */
        $configWriter = $container->offsetGet('config.writer');
        $configWriter->writeConfig($connectionInfo);
    } catch (\Exception $e) {
        $app->render('database-configuration.php', ['error' => $e->getMessage()]);

        return;
    }

    // Redirect to next step - (everything seems to be okay)     $app->redirect($menuHelper->getNextUrl());
})->name('database-configuration')->via('GET', 'POST');

$app->map('/database-import/', function D) use ($app$container$menuHelper) {
    
$connectionInfo = new DatabaseConnectionInformation();
        $connectionInfo = $this->getConnectionInfoFromConfig(SW_PATH . '/config.php', $connectionInfo);
        $connectionInfo = $this->getConnectionInfoFromArgs($input$connectionInfo);
        $connectionInfo = $this->getConnectionInfoFromInteractiveShell(
            $this->IOHelper,
            $connectionInfo
        );

        /** @var ConfigWriter $configWriter */
        $configWriter = $this->container->offsetGet('config.writer');
        $configWriter->writeConfig($connectionInfo);

        $conn = $this->initDatabaseConnection($connectionInfo$container);
        $databaseService = new DatabaseService($conn);

        $databaseService->createDatabase($connectionInfo->databaseName);
        $databaseService->selectDatabase($connectionInfo->databaseName);

        $skipImport = $databaseService->containsShopwareSchema()
            && $input->getOption('no-skip-import')
            && $this->shouldSkipImport();

        
'currency' => (string) $request->request->get('config_shop_currency'),
                'additionalCurrencies' => $availableCurrencies ?: null,
                'country' => (string) $request->request->get('config_shop_country'),
                'email' => (string) $request->request->get('config_mail'),
                'host' => (string) $_SERVER['HTTP_HOST'],
                'schema' => $schema,
                'basePath' => str_replace('/index.php', '', (string) $_SERVER['SCRIPT_NAME']),
                'blueGreenDeployment' => (bool) $session->get(BlueGreenDeploymentService::ENV_NAME),
            ];

            try {
                $this->envConfigWriter->writeConfig($connectionInfo$shop);

                $this->shopConfigurationService->updateShop($shop$connection);
                $this->adminConfigurationService->createAdmin($adminUser$connection);

                $session->remove(DatabaseConnectionInformation::class);
                $session->set('ADMIN_USER', $adminUser);

                return $this->redirectToRoute('installer.finish');
            } catch (\Exception $e) {
                $error = $e->getMessage();
            }
        }
Home | Imprint | This part of the site doesn't use cookies.