diff --git a/AGENTS.md b/AGENTS.md index 892f1ca..8ef4fbe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,7 @@ Goal: modern baseline with minimal overhead and Packagist-readiness. Use these files first when relevant: - README.md for runtime behavior, documented API, and migration notes - composer.json for dependencies, scripts, and autoloading -- class/ for implementation (SimplePhpCache.php) +- src/ for implementation (SimplePhpCache.php) - tests/ for behavior checks (PHPUnit) - CHANGELOG.md for release notes - TODO.md for deferred or optional work @@ -30,7 +30,7 @@ Use these files first when relevant: - Apply a security-first mindset when touching cache keys, file paths, serialization, and user-controlled input. ## Project Structure and Conventions -- Source: `class/SimplePhpCache.php` (classmap autoloading, no namespace) +- Source: `src/SimplePhpCache.php` (PSR-4 autoloading, namespace `Tschueller\SimplePhpCache`) - Tests: `tests/` (PHPUnit 11, PHP 8.2+) - CI: `.github/workflows/ci.yml` (PHP 8.2 / 8.3 / 8.4) - Static analysis: PHPStan level 3 (`phpstan.neon`) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ede3fc..2e1e463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Changed +- **BREAKING**: The `SimplePhpCache` global class is now + `Tschueller\SimplePhpCache\SimplePhpCache`, loaded from `src/` through PSR-4. + Manual includes must be replaced with Composer's autoloader. See the migration + notes in README.md. - **BREAKING**: Variable cache storage switched from PHP serialization to JSON payloads with `SPCJSON1:` marker. Caching PHP objects is no longer supported. - Legacy serialized variable cache files are treated as invalid cache entries, diff --git a/README.md b/README.md index d3b9d59..5bcef6b 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,16 @@ Requirements Preparation ----------- -Include the SimplePhpCache class +Install the package with Composer: - include "SimplePhpCache.php"; + composer require tschueller/simplephpcache + +Load Composer's autoloader and import the class: + +

- \ No newline at end of file + diff --git a/phpstan.neon b/phpstan.neon index e5889ef..2230803 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: level: 3 paths: - - class + - src ignoreErrors: [] diff --git a/class/SimplePhpCache.php b/src/SimplePhpCache.php similarity index 99% rename from class/SimplePhpCache.php rename to src/SimplePhpCache.php index 751a2ec..b79cadf 100644 --- a/class/SimplePhpCache.php +++ b/src/SimplePhpCache.php @@ -5,6 +5,10 @@ * Licensed under the MIT license. */ +namespace Tschueller\SimplePhpCache; + +use RuntimeException; + class SimplePhpCache { /** Prefix marker for JSON variable cache payloads. */ diff --git a/tests/SimplePhpCacheTest.php b/tests/SimplePhpCacheTest.php index 7e424b1..4f4a043 100644 --- a/tests/SimplePhpCacheTest.php +++ b/tests/SimplePhpCacheTest.php @@ -2,9 +2,8 @@ declare(strict_types=1); -require_once __DIR__ . '/../class/SimplePhpCache.php'; - use PHPUnit\Framework\TestCase; +use Tschueller\SimplePhpCache\SimplePhpCache; class SimplePhpCacheTest extends TestCase {