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
- Pass 'content' => '/absolute/path/to/messages.csv' in the options array.
- Check the exact key name and casing — it must be 'content'.
- 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
- Build adapter options in one factory per adapter so required keys are always present.
- Remember the convention: Csv 'content' = file path; NativeArray 'content' = data array.
- Add constructor options to the DI service definition instead of passing partial arrays at call sites.
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
- Cannot find translation key: {key}
- Error opening translation file '{file}'
- Parameter 'locale' is required
- Parameter 'directory' is required
- Translation content was not provided
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/9dc5ad6b557d047f.
Report an issue: GitHub.