ap-lib / routing-cache
Caching of an unchanging routing index is typically prepared on one computer and used on another.
dev-main
2025-03-14 06:55 UTC
Requires
- php: ^8.3
- ap-lib/routing: dev-main
Requires (Dev)
- phpunit/phpunit: 10.5.*
This package is auto-updated.
Last update: 2025-03-14 06:55:43 UTC
README
Caching of an unchanging routing index is typically prepared on one computer and used on another.
Installation
composer require ap-lib/routing-cache
Features
- Interface for saving and loading arrays what include links to classes to full related code
- Implementation for saving and loading arrays to a PHP file
Requirements
- PHP 8.3 or higher
Getting Started
// make routing $routing = new Hashmap(); // setup index $index = $routing->getIndexMaker(); $index->addEndpoint(Method::GET, "/", new Endpoint( [MainController::class, "handlerRoot"] )); $index->addEndpoint(Method::GET, "/hello", new Endpoint( [MainController::class, "handlerHelloName"] )); // Set up the cache object (in this case, it's just a filename) $cache = new PhpFileRoutingCache("data.php"); // Store the index in the cache $cache->set($index); // Retrieve the array to init routing index from the cache $retrieved_array = $cache->get();