phalcon/cphalcon · error · Phalcon\Mvc\Model\MetaData\Exceptions\MetaDataDirectoryNotWritable
Meta-Data directory cannot be written
Error message
Meta-Data directory cannot be written
What it means
Stream::write() failed to persist the compiled meta-data PHP file into metaDataDir (phpFilePutContents returned false or threw), so throwWriteException() raises MetaDataDirectoryNotWritable. This is a filesystem permission/path failure, and any wrapped exception is swallowed and replaced by this sentinel error.
Solutions
- Make the meta-data directory writable by the web-server user (chown/chmod)
- Check disk space and open_basedir/safe-path restrictions
- Point the meta-data dir option to a valid, writable path
Example fix
chmod 775 /var/cache/phalcon-metadata && chown www-data:www-data /var/cache/phalcon-metadata
Defensive patterns
Strategy: try-catch
Prevention
- Provision and verify the storage directory during deployment
- Cache to a dedicated writable cache volume instead of code directories
When it happens
Trigger: Thrown at phalcon/Mvc/Model/MetaData/Stream.zep:100 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/8234f5f1373ef25b.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/MetaData/Stream.zep:100
try {
let path = this->metaDataDir . prepare_virtual_path(key, "_") . ".php";
if false === this->phpFilePutContents(path, "<?php return " . var_export(data, true) . "; ") {
this->throwWriteException(option);
}
} catch \Exception {
this->throwWriteException(option);
}
}
/**
* Throws an exception when the metadata cannot be written
*/
private function throwWriteException(var option) -> void
{
if option {
throw new MetaDataDirectoryNotWritable();
} else {
trigger_error(
"Meta-Data directory cannot be written"
);
}
}
}
View on GitHub (pinned to b7419de9cd)