Directories under var/
Part 8, reference 28. Everything an installation writes at run time is under var/. Knowing what is where tells you
what a cache clear removes, what a backup must keep, and where your extension may write.
The layout
| Path | Holds | Delete? | Back up? |
|---|---|---|---|
var/<site>/ | the site's var directory (site.ini [FileSettings] VarDir, var by default, usually set to var/<site>); eZSys::varDirectory() | ||
var/<site>/cache/ | compiled templates, view caches, settings caches, packed CSS and JS, everything a cache clear removes; eZSys::cacheDirectory() | yes, through the cache commands | no |
var/<site>/storage/ | uploaded files and images of content; eZSys::storageDirectory() | never | yes |
var/<site>/log/ | the site's log files | rotate, do not delete blindly | as policy requires |
var/log/ | logs written before a site is known, and the default for eZLog::write() | rotate | as policy requires |
var/autoload/ | generated autoload arrays of extensions and overrides (ezp_extension.php, ezp_override.php); the kernel's own is autoload/ezp_kernel.php at the root | regenerated by the autoload command | no |
<site> is a name the installation chooses (often site). Some installations add their own folders; the kernel's
own extensions may keep caches and job data in subfolders of the site's var directory.
Rules for an extension
- Ask for the path:
eZSys::varDirectory(),eZSys::cacheDirectory(),eZSys::storageDirectory(); never writevar/siteinto code (eZSys and eZExtension). - Caches in
cacheDirectory()/myext/: anything you can rebuild. A cache clear may delete it at any time. - Data in the database or storage: anything you cannot rebuild. Never keep the only copy of data in the cache.
- Through the cluster file handler for files more than one request reads, so the extension works on clusters (eZFile, eZDir and cluster file handlers).
- With the installation's permissions:
eZDir::mkdir()andeZFile::create()use the configured file modes, so the web server and command line scripts can both read what the other wrote (File modes). - Nothing secret in var/ if it is web-readable. The web server configuration must not serve
var/except storage and the packed public files; do not rely on obscure file names.
Clearing by hand
Never delete inside var/ with rm to "clear caches": cluster setups keep a database record per file, and the next
request may find a record without its file. Use php bin/php/ezcache.php or ./console exp:cache
(Cache tags, cache blocks and clearing caches).
Related pages
- Previous: Console commands for developers
- Next: Error codes and module results
- Debug output and logs for developers
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.