Configuration ​
The whole cache warmup process can be customized with a various set of configuration options. Read more about how to provide those configuration options on this page.
Config adapters ​
Each configuration option can be set by a dedicated config adapter. At the moment, the following adapters are supported:
IMPORTANT
Config adapters are loaded from top to bottom. That means, adapters which are loaded later receive higher priority and may override configuration options provided by previously loaded config adapters.
Configuration file ​
You can provide configuration files in the following formats:
JSON and YAML ​
For JSON and YAML files, the name of each configuration option can be looked up in the configuration reference. It must be written in lowerCamelCase, e.g. the --crawler-options
command parameter must be configured as crawlerOptions
:
{
"sitemaps": [
"https://www.example.org/sitemap.xml"
],
"exclude": [
"*foo*"
]
}
sitemaps:
- https://www.example.org/sitemap.xml
exclude:
- '*foo*'
JSON schema ​
To make it easier for you to compose your configuration files, you can reference the available JSON schema in your JSON file and enable autocompletion in your IDE:
{
"$schema": "https://cache-warmup.dev/config.schema.json",
"sitemaps": [
"https://www.example.org/sitemap.xml"
],
"exclude": [
"*foo*"
]
}
PHP ​
PHP configuration files must return a closure which receives the current instance of EliasHaeussler\CacheWarmup\Config\CacheWarmupConfig
. They may also return a (new) instance to override the current one:
use EliasHaeussler\CacheWarmup;
return static function (CacheWarmup\Config\CacheWarmupConfig $config) {
$config->addSitemap(
CacheWarmup\Sitemap\Sitemap::createFromString('https://www.example.org/sitemap.xml'),
);
$config->addExcludePattern(
CacheWarmup\Config\Option\ExcludePattern::create('*foo*'),
);
return $config;
};
Command parameters ​
The library accepts a various set of command parameters. Each command parameter reflects an available configuration option:
./cache-warmup.phar "https://www.example.org/sitemap.xml" --exclude "*foo*"
In addition, the --config
option allows to provide the path to a configuration file:
./cache-warmup.phar --config cache-warmup.json
All available command parameters are reflected in the configuration reference. You can also run the command with --help
to see a detailed explanation of all available command parameters.
Environment variables ​
Several configuration options can also be configured using environment variables. Each environment variable is prefixed with CACHE_WARMUP_
, followed by the configuration option in SCREAMING_SNAKE_CASE.
Example:
- The
sitemaps
option is expected asCACHE_WARMUP_SITEMAPS
- The
crawlerOptions
option is expected asCACHE_WARMUP_CRAWLER_OPTIONS
Value mapping ​
The following value transformation between environment variables and configuration options exists:
Lists: Values must be separated by comma:
CACHE_WARMUP_SITEMAPS="https://www.example.org/sitemap.xml, /var/www/html/sitemap.xml"
Booleans: Values matching true
, yes
or 1
are interpreted as true
:
CACHE_WARMUP_PROGRESS="true"
CACHE_WARMUP_PROGRESS="yes"
CACHE_WARMUP_PROGRESS="1"
All other values are converted to their expected type:
# Internally converted to an integer value
CACHE_WARMUP_LIMIT="50"