phalcon/cphalcon · error · Phalcon\Html\Exceptions\ServiceNotRegistered
Service {name} is not registered
Error message
Service {name} is not registered What it means
Phalcon\Html\TagFactory::newInstance() creates helpers from a closure registry keyed by service name ('inputText', 'select', ...). Requesting a name that was never registered throws ServiceNotRegistered from the factory before any helper can be instantiated.
Source
Thrown at phalcon/Html/TagFactory.zep:212
public function has(string name) -> bool
{
return isset this->factories[name];
}
/**
* Create or return a cached instance of the helper.
*
* @param string $name
*
* @return object
* @throws \Phalcon\Html\Exception
*/
public function newInstance(string name) -> object
{
var factory;
if !isset this->factories[name] {
throw new ServiceNotRegistered(name);
}
if !isset this->instances[name] {
let factory = this->factories[name];
let this->instances[name] = call_user_func(factory);
}
return this->instances[name];
}
/**
* Register a helper via a zero-argument Closure. The Closure is invoked on
* the first matching `newInstance()` call and its return value is cached.
* Passing a new definition clears any cached instance so the next call to
* `newInstance()` rebuilds it.
*
* @param string $name
* @param Closure $definitionView on GitHub (pinned to b7419de9cd)
Solutions
- Check the key first: if ($factory->has($name)) { $helper = $factory->newInstance($name); }
- Register the custom helper: $factory->set('myHelper', fn() => new MyHelper($deps))
- Match the exact service name against the factory's registered keys for your Phalcon version
Example fix
// before
$helper = $factory->newInstance('inputData'); // typo, not registered
// after
$helper = $factory->newInstance('inputText'); Defensive patterns
Strategy: validation
Validate before calling
if ($factory->has($name)) {
$helper = $factory->newInstance($name);
} else {
throw new \InvalidArgumentException("Unknown tag helper service: {$name}");
} Try / catch
try {
$helper = $factory->newInstance($name);
} catch (\Phalcon\Html\Exceptions\ServiceNotRegistered $e) {
// helper key wrong or unregistered; log the requested name to find the typo
$logger->error($e->getMessage());
throw $e;
} Prevention
- Register custom helpers in the TagFactory's composition root before first use
- Centralize helper names as constants instead of passing raw strings from templates
- After upgrading Phalcon, diff the factory's service list against the names your code requests
When it happens
Trigger: Calling $factory->newInstance('inputData') when the registered service is 'inputText'; requesting a helper key that was renamed or removed between Phalcon versions; forgetting to register a custom helper via set() before requesting it.
Common situations: Custom tag helpers registered in DI setup code that runs after first use; upgrades where helper keys changed; typos in helper names passed from configuration or templates.
Related errors
- Service '{name}' not registered
- Form '{name}' is not registered in the FormsLocator
- There is no form with name='{name}'
- Value at index: "{key}" type: "{type}" cannot be rendered
- {message}
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/4609a515264f30a9.
Report an issue: GitHub.