PHPackages                             uea/slimcache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. uea/slimcache

ActiveLibrary[Caching](/categories/caching)

uea/slimcache
=============

File based cache system of slim 3 php frameworks.

226[1 issues](https://github.com/ugurethemaydin/slimCache/issues)PHP

Since Feb 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ugurethemaydin/slimCache)[ Packagist](https://packagist.org/packages/uea/slimcache)[ RSS](/packages/uea-slimcache/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

slimCache
=========

[](#slimcache)

File based cache system of slim 3 php frameworks.

The cache is a simple file based cache, I needed something for a very specific situation where I had many external API requests (essentially an API aggregator) to make and within a given time period they always made my routes give the same output.

I didn't need a database or anything fancy, and wasn't too fussed about performance.

So a file based cache made a lot of sense.

Installation
------------

[](#installation)

Installation is done via composer

```
composer require uea/slimcache dev-master
```

Requirements
------------

[](#requirements)

This middleware works with slim 3.0

Setup
-----

[](#setup)

The middleware conforms to slims normal injection requirements. The example below is the basic setup of the cache. Once this has been implemented, it will automatically load any active cache records for the route currently being called and halt the execution of the application.

```
//Start up a new slim app
$app = new App($container);

// Add file cache middleware
$cache = new \UEA\SlimCache\Cache($app);
$app->add($cache);
```

Usage
-----

[](#usage)

To use the cache you simple need to cache the output of your route before returning it. The add method takes 3 arguments, the first one is the route name. The second one is the content, and the third argument is the response code status (e.g. 200) and fourthly duration of the cache in seconds. The default length is 1 hour. The second argument for the cache is the directory to store the cache files in. The directory must be writeable to the web user.

```
//Start up a new slim app
$app = new App($container);

// Add file cache middleware
$cache = new \UEA\SlimCache\Cache($app, 'path/to/cacheDirectory');
$app->add($cache);

//Configure the "foo" route and cache the output
$slim->get('/foo', function(\Slim\Http\Request $request, \Slim\Http\Response $response, $args) use ($cache) {
$response = 'foo response string';
$cache->add('/foo', $response);
return $response;
}
);
```

Alternatively you can tell the cache to store all routes called by simple placing the following line after you have run the slim app

```
//Run the slim app (like normal)
$app->run();

//Place the global cache afterwards, the next request at this route will be cached
$cache->add($slim->request->getUri()->getPath(), $slim->response->getBody()->__toString());
```

The cache has a few other simple methods. They are flush, get, remove. They essentially do what they say on the tin:

```
$cache = new \UEA\SlimCache\Cache($slim)

//Flush removes all entries
$cache->flush();

//Remove a single cache entry
$cache->remove('/foo');

//Get returns what is stored in the cache
$response = $cache->get('/foo');
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/24ae7e0e98c0b43a2ffb832f28d46ba25ddff82c5628d32dd53fed809f53dd78?d=identicon)[ugurethemaydin](/maintainers/ugurethemaydin)

---

Top Contributors

[![ugurethemaydin](https://avatars.githubusercontent.com/u/3869305?v=4)](https://github.com/ugurethemaydin "ugurethemaydin (11 commits)")

---

Tags

cachefileframeworkmiddlewarephpslim

### Embed Badge

![Health badge](/badges/uea-slimcache/health.svg)

```
[![Health](https://phpackages.com/badges/uea-slimcache/health.svg)](https://phpackages.com/packages/uea-slimcache)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
