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 EliasHaeussler\CacheWarmup\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 EliasHaeussler\CacheWarmup\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:
EliasHaeussler\CacheWarmup\Crawler\ConcurrentCrawler
EliasHaeussler\CacheWarmup\Crawler\OutputtingCrawler
You can find all available crawler options in the crawlerOptions
configuration reference.