Service providers are the canonical extension point for the WP SSR Framework. Each provider has two responsibilities:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Ahondev/portfolio-v2/llms.txt
Use this file to discover all available pages before exploring further.
register() binds things into the services container before any hooks run, and boot() adds WordPress action/filter hooks and starts services. Providers are collected by the Kernel, sorted by their $priority integer, and executed in order — giving you total control over the sequence in which features initialise.
ServiceProviderInterface
Every provider must implement this two-method contract.
Called synchronously during
Kernel::boot(), before any WordPress hooks fire. Use it to perform lightweight setup that other providers may depend on at register() time — for example, adding an entry to the services container.Deferred to the WordPress
init hook at the provider’s $priority. This is where you call add_action(), add_filter(), or start services that depend on WordPress being initialised.BaseServiceProvider
Extend this class to create your own providers. It implements ServiceProviderInterface with empty default methods so you only need to override what you use.
$priority
Controls when
boot() is called relative to other providers. Lower numbers run first. The ProviderManager passes this value as the priority argument to add_action('init', ...). Defaults to 0.Inherited from Base
BaseServiceProvider extends Base, giving every provider access to two helper methods:
service()
Resolves a class from the ServicesContainer. The instance is lazy-created on first access and cached for the lifetime of the request.
remember()
A transient-backed cache helper. On the first call the callback is executed and its return value is stored as a WordPress transient; subsequent calls within the TTL window return the cached value.
Unique transient key.
Time-to-live in seconds.
The computation to cache. Executed only when no valid transient exists.
ServicesContainer
A minimal service locator that lazy-instantiates and caches service instances by class name.
resolve()
Returns the singleton instance of $class, constructing it on first call. Throws Exception if the class does not exist.
ServicesContainer constructs each class with new $class — no dependency injection. Design your services to be constructable without arguments, and pull dependencies via $this->service() inside method bodies if needed.ProviderManager
The internal engine that registers and boots providers. Called once by Kernel::boot().
Registration flow
Validate
Checks that the class exists and extends
BaseServiceProvider. Throws RuntimeException on failure.Built-in Providers
The following providers ship with the framework and are registered inwp-ssr.php. They run in the order listed, subject to their individual $priority values.
Creating a Custom Provider
Priority Reference
| Priority | Provider |
|---|---|
| 0 (default) | AppServiceProvider, RateLimitServiceProvider, CacheServiceProvider, AnalyticsServiceProvider, RoutingServiceProvider, SSGServiceProvider |
| 40 | SEOServiceProvider |
Provider boot priority maps directly to the WordPress
init hook priority. Standard WordPress themes and plugins hook at priority 10 by default. Providers with $priority = 0 run before them; $priority = 40 runs after.