phalcon/cphalcon · error · Phalcon\Container\Exceptions\ParameterNotFound
Parameter '{name}' not found
Error message
Parameter '{name}' not found What it means
Parameters live in a separate store from services. getParameter() does a plain key lookup in that store and throws ParameterNotFound when the key was never set with setParameter(). There is no fallback to config files, environment variables, or service names.
Source
Thrown at phalcon/Container/Container.zep:286
if (!array_key_exists(name, this->instances)) {
throw new InstanceNotFound(name);
}
return this->instances[name];
}
/**
* Return a parameter
*
* @param string $name
*
* @return mixed
* @throws ParameterNotFound
*/
public function getParameter(string name) -> mixed
{
if (!array_key_exists(name, this->parameters)) {
throw new ParameterNotFound(name);
}
return this->resolveParameter(name);
}
/**
* Return the resolver
*
* @return Resolver
*/
public function getResolver() -> <Resolver>
{
return this->resolver;
}
/**
* Resolve an return a service
*View on GitHub (pinned to b7419de9cd)
Solutions
- Set it first: $container->setParameter('db.host', $config->path('db.host'))
- Guard with $container->hasParameter('db.host') before reading, or with a default: $container->hasParameter(...) ? $container->getParameter(...) : $default
- For environment-backed values, inject a Lazy\Env object as a service argument instead of reading a parameter
- Check exact key spelling — lookup is case-sensitive with no nested traversal
Example fix
// before
$host = $container->getParameter('dbhost'); // ParameterNotFound
// after
$host = $container->hasParameter('dbhost')
? $container->getParameter('dbhost')
: $container->getParameter('db.host'); Defensive patterns
Strategy: validation
Validate before calling
$host = $container->hasParameter('db.host')
? $container->getParameter('db.host')
: 'localhost'; Try / catch
use Phalcon\Container\Exceptions\ParameterNotFound;
try {
$host = $container->getParameter('db.host');
} catch (ParameterNotFound $e) {
$host = $_ENV['DB_HOST'] ?? 'localhost';
} Prevention
- Register all parameters in one provider that runs first during bootstrap
- Keep parameter keys in one constants class shared by writer and reader code
- Use Lazy\Env for environment-backed values instead of duplicating them as parameters
When it happens
Trigger: Calling $container->getParameter('db.host') without a prior setParameter('db.host', ...); typo or case mismatch in the key; parameters being loaded inside a ServiceProvider that has not run yet; expecting nested/dotted access to work.
Common situations: Config wiring where setParameter() calls live in a provider executed later in bootstrap; renamed config keys after refactoring; assuming getParameter() merges environment or Config values (it does not).
Related errors
- Invalid module definition for module '{moduleName}': The mod
- Invalid module definition for module '{moduleName}': The mod
- To use 'array' adapter you have to specify the 'config' as a
- Configuration file {fileName} cannot be loaded
- Configuration file {fileName} cannot be loaded
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/a21f2579c29bb4b7.
Report an issue: GitHub.