Skip to content

Parser options 4.0+

📝 Name: parserOptions · 🖥️ Option: --parser-options

Additional config for configurable parsers.

INFO

These options only apply to configurable parsers. If the configured parser does not implement the required interface, a warning is shown.

Example

Pass parser options in the expected input format.

IMPORTANT

When passing parser options as command parameter or environment variable, make sure to pass them as JSON-encoded string.

bash
./cache-warmup.phar --parser-options '{"request_options": {"proxy": "http://localhost:8125"}}'
json
{
    "parserOptions": {
        "request_options": {
            "proxy": "http://localhost:8125"
        }
    }
}
php
use EliasHaeussler\CacheWarmup;

return static function (CacheWarmup\Config\CacheWarmupConfig $config) {
    $config->setParserOption('request_options', [
        'proxy' => 'http://localhost:8125',
    ]);

    return $config;
};
yaml
parserOptions:
  request_options:
    proxy: 'http://localhost:8125'
bash
CACHE_WARMUP_PARSER_OPTIONS='{"request_options": {"proxy": "http://localhost:8125"}}'

Option Reference

The default parser is implemented as configurable parser:

The following configuration options are currently available for the default parser:

request_headers 4.0+

🎨 Type: array<string, mixed> · 🐝 Default: ['User-Agent' => '<default user-agent>']

A list of HTTP headers to send when fetching external XML sitemaps.

INFO

The default User-Agent is built in ConcurrentCrawlerTrait::getRequestHeaders().

bash
./cache-warmup.phar --parser-options '{"request_headers": {"X-Foo": "bar", "User-Agent": "Foo-Crawler/1.0"}}'
json
{
    "parserOptions": {
        "request_headers": {
            "X-Foo": "bar",
            "User-Agent": "Foo-Crawler/1.0"
        }
    }
}
php
use EliasHaeussler\CacheWarmup;

return static function (CacheWarmup\Config\CacheWarmupConfig $config) {
    $config->setParserOption('request_headers', [
        'X-Foo' => 'bar',
        'User-Agent' => 'Foo-Parser/1.0',
    ]);

    return $config;
};
yaml
parserOptions:
  request_headers:
    X-Foo: bar
    User-Agent: 'Foo-Parser/1.0'
bash
CACHE_WARMUP_PARSER_OPTIONS='{"request_headers": {"X-Foo": "bar", "User-Agent": "Foo-Parser/1.0"}}'

request_options 4.0+

🎨 Type: array<string, mixed> · 🐝 Default: []

Additional request options used when fetching external XML sitemaps.

bash
./cache-warmup.phar --parser-options '{"request_options": {"verify": false}}'
json
{
    "parserOptions": {
        "request_options": {
            "verify": false
        }
    }
}
php
use EliasHaeussler\CacheWarmup;

return static function (CacheWarmup\Config\CacheWarmupConfig $config) {
    $config->setParserOption('request_options', [
        'verify' => false,
    ]);

    return $config;
};
yaml
parserOptions:
  request_options:
    verify: false
bash
CACHE_WARMUP_PARSER_OPTIONS='{"request_options": {"verify": false}}'

Released under the GNU General Public License 3.0 (or later)