Skip to main content
Version: 2026.1

Env Var Definitions

Env var definitions tell the installer which configuration values to collect from the user, how to validate them, and how to write them as environment variables to .env.local.

Each definition implements EnvVarDefinitionInterface and is registered via the install profile's getEnvVarDefinitions() method or injected at runtime with the --env-definition CLI option.

Built-in Definitions

Pimcore ships with definitions for common infrastructure services. The "Required" column indicates whether isRequired() returns true. Required definitions cannot be skipped during interactive installation -- the user must provide values. Optional definitions (isRequired(): false) can be skipped by pressing Enter without input.

DefinitionKeyEnv Var(s)Required
DatabaseEnvVarDefinitiondatabaseDATABASE_URLYes
ProductRegistrationEnvVarDefinitionproduct-registrationPIMCORE_PRODUCT_KEY, PIMCORE_INSTANCE_IDENTIFIER, PIMCORE_ENCRYPTION_SECRETYes
OpenSearchEnvVarDefinitionopensearchPIMCORE_OPENSEARCH_DSNYes
ElasticsearchEnvVarDefinitionelasticsearchPIMCORE_ELASTICSEARCH_DSNYes
DoctrineMessengerEnvVarDefinitionmessenger-doctrinePIMCORE_MESSENGER_TRANSPORT_DSN_PREFIXYes
AmqpMessengerEnvVarDefinitionmessenger-amqpPIMCORE_MESSENGER_TRANSPORT_DSN_PREFIXYes
RedisEnvVarDefinitionredisREDIS_URLNo
MailerEnvVarDefinitionmailerMAILER_DSNNo
GotenbergEnvVarDefinitiongotenbergGOTENBERG_BASE_URLNo
MercureEnvVarDefinitionmercureMERCURE_URL, MERCURE_SERVER_URL, MERCURE_JWT_KEYYes

EnvVarDefinitionInterface

MethodReturn TypeDescription
getKey()stringUnique key identifying this definition (e.g., database, redis). Used with --skip-validation.
getLabel()stringHuman-readable label for CLI prompts.
isRequired()boolWhether this definition is mandatory. Optional definitions can be skipped in interactive mode.
getSectionName()stringSection name for .env.local markers (uses Composer package name, e.g., pimcore/pimcore).
getParameters()list<ConfigParameter>Parameter definitions to collect from the user.
resolveEnvVars(array $collectedValues)array<string, string>Transforms collected values into final env var name/value pairs.
validate(array $collectedValues)list<string>Validates collected values (e.g., test DB connection). Returns error messages or empty array.

ConfigParameter

Each ConfigParameter represents a single value to collect:

PropertyTypeDescription
envVarNamestringThe environment variable name this maps to (e.g., DATABASE_URL).
labelstringHuman-readable label for the CLI prompt.
typeParameterTypeValue type: String, Secret, Url, Integer, Boolean, Choice.
requiredboolWhether a value is mandatory (default true).
defaultValue?stringDefault value shown in the prompt (default null).
description?stringHelp text shown below the prompt (default null).
choiceslist<string>Available choices when type is Choice.

ParameterHintProviderInterface

Definitions can implement ParameterHintProviderInterface to provide dynamic hints based on previously collected values. This is useful when a default value depends on another parameter (e.g., deriving a Redis session URL from the base Redis URL).

MethodReturn TypeDescription
getParameterHint(string $envVarName, array $collectedSoFar)?stringReturns a hint/default value for the given parameter based on values collected so far. Return null for no hint.

Creating Custom Definitions

Using SimpleEnvVarDefinition

For simple env vars that only need basic validation (non-empty, URL format), use SimpleEnvVarDefinition:

use Pimcore\Bundle\InstallBundle\EnvVarDefinition\ConfigParameter;
use Pimcore\Bundle\InstallBundle\EnvVarDefinition\Definitions\SimpleEnvVarDefinition;
use Pimcore\Bundle\InstallBundle\EnvVarDefinition\ParameterType;

new SimpleEnvVarDefinition(
key: 'my-api',
label: 'My API Service',
sectionName: 'my-project/api',
parameters: [
new ConfigParameter(
envVarName: 'MY_API_URL',
label: 'API URL',
type: ParameterType::Url,
defaultValue: 'https://api.example.com',
),
new ConfigParameter(
envVarName: 'MY_API_KEY',
label: 'API Key',
type: ParameterType::Secret,
),
],
);

Implementing EnvVarDefinitionInterface

For definitions that require custom validation (e.g., testing a connection), implement EnvVarDefinitionInterface directly:

<?php
declare(strict_types=1);

namespace App\Installer;

use Pimcore\Bundle\InstallBundle\EnvVarDefinition\ConfigParameter;
use Pimcore\Bundle\InstallBundle\EnvVarDefinition\EnvVarDefinitionInterface;
use Pimcore\Bundle\InstallBundle\EnvVarDefinition\ParameterType;

final readonly class SolrEnvVarDefinition implements EnvVarDefinitionInterface
{
public function getKey(): string
{
return 'solr';
}

public function getLabel(): string
{
return 'Apache Solr';
}

public function isRequired(): bool
{
return false; // optional service
}

public function getSectionName(): string
{
return 'my-project/solr';
}

public function getParameters(): array
{
return [
new ConfigParameter(
envVarName: 'SOLR_DSN',
label: 'Solr URL',
type: ParameterType::Url,
defaultValue: 'http://solr:8983/solr/pimcore',
),
];
}

public function resolveEnvVars(array $collectedValues): array
{
return ['SOLR_DSN' => $collectedValues['SOLR_DSN'] ?? ''];
}

public function validate(array $collectedValues): array
{
$url = $collectedValues['SOLR_DSN'] ?? '';

if ($url === '') {
return ['Solr URL must not be empty.'];
}

// Test connection
$ch = curl_init($url . '/admin/ping');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode !== 200) {
return [sprintf('Could not reach Solr at %s (HTTP %d).', $url, $httpCode)];
}

return [];
}
}

Adding Definitions via CLI

Use --env-definition to inject additional definitions alongside those defined in the profile, without modifying the profile itself:

When running via Docker, prepend docker compose exec php to the command below.

vendor/bin/pimcore-install \
--install-profile='App\Installer\SkeletonProfile' \
--env-definition='App\Installer\SolrEnvVarDefinition' \
--env-definition='App\Installer\RedisSessionDefinition'

These definitions are collected and validated in addition to the profile's definitions. This is useful for project-specific infrastructure that only some deployments need.