docs: add CLAUDE.md project instructions

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-13 13:38:02 +00:00
parent 56f66788c8
commit 22566373c5

32
CLAUDE.md Normal file
View file

@ -0,0 +1,32 @@
# 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 in `src/{ProviderName}/`
- All public methods return `Core\Plug\Response` (from the parent `lthn/php` package)
- Configuration accessed via Laravel's `config()` helper
- Errors logged via `Illuminate\Support\Facades\Log` before 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.