1.7 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Overview
This is lthn/php-plug-cdn, a Composer library providing CDN provider integrations for the Plug framework. It depends on lthn/php (the core Plug framework) which supplies Core\Plug\Response, BuildsResponse, and UsesHttp traits. Licensed under EUPL-1.2.
Architecture
Driver-based manager pattern. CdnManager is the entry point — it resolves CDN provider operations by driver name (default: bunny, configurable via cdn.driver).
Each driver registers two operation classes keyed by contract interface:
Purgeable— cache purging (single URL, bulk, full zone, tag-based)HasStats— statistics and bandwidth reporting
New providers are added by: (1) creating classes implementing the contracts under src/{Provider}/, (2) registering them in CdnManager::$drivers or via CdnManager::extend().
Bunny CDN implementation (src/Bunny/) uses the Bunny.net REST API. Config keys: cdn.bunny.api_key, cdn.bunny.pull_zone_id. Both classes use the UsesHttp and BuildsResponse traits from lthn/php.
Conventions
- PHP 8.2+ with
declare(strict_types=1)on all files - PSR-4 autoloading:
Core\Plug\Cdn\→src/ - Contracts live in
src/Contract/; provider implementations insrc/{ProviderName}/ - All public methods return
Core\Plug\Response(from the parentlthn/phppackage) - Configuration accessed via Laravel's
config()helper - Errors logged via
Illuminate\Support\Facades\Logbefore returning error responses
Development
No tests, linting, or build commands exist in this package yet. It is installed as a dependency via Composer into a Laravel-based application.