Skip to content

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.

php
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:

⚙️ Configurable Crawler

Allows to customize crawling behavior using crawler options.

📝 Logging Crawler

Provides logging features for cache warmup requests.

🧯 Stoppable Crawler

Makes crawlers stop further processing in case of a failure.

🗣️ Verbose Crawler

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:

⚙️ Configurable Parser

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.

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