API Reference
The library provides a PHP API for use in other systems and applications, e.g. within a content management system.
INFO
Only a limited set of configuration options is available within the PHP API. For a greater experience, we suggest to use the library from command line along with the whole set of available configuration options.
CacheWarmer
The CacheWarmer
class serves as main entrypoint for the PHP API.
use EliasHaeussler\CacheWarmup;
// Instantiate and run cache warmer
$cacheWarmer = new CacheWarmup\CacheWarmer();
$cacheWarmer->addSitemaps('https://www.example.org/sitemap.xml');
$result = $cacheWarmer->run();
// Get successful and failed URLs
$successfulUrls = $result->getSuccessful();
$failedUrls = $result->getFailed();
Check out all available options and methods to get an overview about possible API opportunities.
Crawler
URLs in XML sitemaps are processed by crawlers implementing Crawler\Crawler
. Read more about how to create a custom crawler.
In addition, there exist different variations of crawler implementations:
Allows to customize crawling behavior using crawler options.
Provides logging features for cache warmup requests.
Makes crawlers stop further processing in case of a failure.
Enhances the cache warmup process with user-oriented output.
Default crawlers
The library ships with two default crawlers:
You can find all available crawler options in the crawlerOptions
configuration reference.
Parser
XML sitemaps are fetched and parsed by parsers implementing Xml\Parser
. Read more about how to create a custom parser.
In addition, there exist different variations of parser implementations:
Allows to customize parsing behavior using parser options.
Default parser
The library ships with a default parser:
You can find all available parser options in the parserOptions
configuration reference.