phalcon/cphalcon · error · Phalcon\Translate\Exceptions\MissingRequiredParameter

Parameter 'content' is required

Error message

Parameter 'content' is required

What it means

The Csv translate adapter loads its dictionary from a CSV file whose path must be supplied in the 'content' option; Csv::__construct() checks isset options['content'] right after the parent constructor and throws Phalcon\Translate\Exceptions\MissingRequiredParameter('content') when it is absent (phalcon/Translate/Adapter/Csv.zep:50).

Source

Thrown at phalcon/Translate/Adapter/Csv.zep:50

    protected array translate = [];

    /**
     * Csv constructor.
     *
     * @phpstan-param translate_csv_options $options
     *
     * @throws Exception
     */
    public function __construct(
        <InterpolatorFactory> interpolator,
        array options
    ) {
        var delimiter, enclosure, escape;

        parent::__construct(interpolator, options);

        if unlikely !isset options["content"] {
            throw new MissingRequiredParameter("content");
        }

        if isset options["delimiter"] {
            let delimiter = options["delimiter"];
        } else {
            let delimiter = ";";
        }

        if isset options["enclosure"] {
            let enclosure = options["enclosure"];
        } else {
            let enclosure = "\"";
        }

        if isset options["escape"] {
            let escape = options["escape"];
        } else {
            let escape = "\\";

View on GitHub (pinned to b7419de9cd)

Solutions

  1. Pass 'content' => '/absolute/path/to/messages.csv' in the options array.
  2. Check the exact key name and casing — it must be 'content'.
  3. When wiring in DI, define the service with the full options array including 'content' so every instantiation is complete.

Example fix

// before
$t = new Csv($factory, ['delimiter' => ',']); // no content

// after
$t = new Csv($factory, [
    'content'   => dirname(__DIR__) . '/messages/en.csv',
    'delimiter' => ',',
]);
Defensive patterns

Strategy: validation

Validate before calling

$required = ['content'];
$missing = array_diff($required, array_keys($options));
if ($missing !== []) {
    throw new InvalidArgumentException('Csv adapter missing options: ' . implode(', ', $missing));
}
$t = new Csv($factory, $options);

Prevention

When it happens

Trigger: new Csv($interpolatorFactory, ['delimiter' => ',']) — any options array without a 'content' key. Note that for this adapter 'content' is the CSV file path, not the translations array.

Common situations: Copying a NativeArray config (where 'content' is the data array) to Csv; naming the key 'file' or 'path' instead of 'content'; options arrays built conditionally where the content assignment is skipped; typos in the option name.

Related errors


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/9dc5ad6b557d047f. Report an issue: GitHub.