PHPackages                             sergeymakinen/yii2-php-file-cache - 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. sergeymakinen/yii2-php-file-cache

AbandonedArchivedYii2-extension[Caching](/categories/caching)

sergeymakinen/yii2-php-file-cache
=================================

Yii 2 PHP file cache

v2.1.0(8y ago)12.1k1MITPHP

Since Dec 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sergeymakinen/yii2-php-file-cache)[ Packagist](https://packagist.org/packages/sergeymakinen/yii2-php-file-cache)[ Docs](https://github.com/sergeymakinen/yii2-php-file-cache)[ RSS](/packages/sergeymakinen-yii2-php-file-cache/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (5)Used By (1)

Yii 2 PHP file cache
====================

[](#yii-2-php-file-cache)

Yii 2 cache component that uses native PHP files to store cache data so:

- it's possible to improve a PHP performance by storing a precompiled data bytecode in a shared memory (objects will be serialized though)
- allows to include an arbitrary PHP code to bootstrap something
- it's fully compatible with the standard [Yii 2 cache interface](http://www.yiiframework.com/doc-2.0/yii-caching-cache.html)

[![Code Quality](https://camo.githubusercontent.com/0c620f796117493c405883072bc6970cf954d3301a68093b0f14dd558be219f1/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7365726765796d616b696e656e2f796969322d7068702d66696c652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sergeymakinen/yii2-php-file-cache) [![Build Status](https://camo.githubusercontent.com/26cdf119ab74ea386e6045c70a7c68b90467cb82bd555ad706169cb0fdb67574/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7365726765796d616b696e656e2f796969322d7068702d66696c652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/sergeymakinen/yii2-php-file-cache) [![Code Coverage](https://camo.githubusercontent.com/74a997af688e0e63a8c25dc75e6508c359bd221827ceb23c95ee9c1f5caf93cb/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f7365726765796d616b696e656e2f796969322d7068702d66696c652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/sergeymakinen/yii2-php-file-cache) [![SensioLabsInsight](https://camo.githubusercontent.com/deba9322728bf5725f26a5040a870126bd398ec3e276b65a7d56d87c832a46a0/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f63623934376566612d393066332d343035342d613334382d3230643637333237653861332e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/cb947efa-90f3-4054-a348-20d67327e8a3)

[![Packagist Version](https://camo.githubusercontent.com/221e9f282feae8cd1ca273af6f5a82a9ba205883fdb651feb3a622f94c41d8c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7365726765796d616b696e656e2f796969322d7068702d66696c652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sergeymakinen/yii2-php-file-cache) [![Total Downloads](https://camo.githubusercontent.com/b5e7124321dac40f85b4a669d2fb059cfd8205eae78ee78b18211815a3bfab65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7365726765796d616b696e656e2f796969322d7068702d66696c652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sergeymakinen/yii2-php-file-cache) [![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

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

[](#installation)

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```
composer require "sergeymakinen/yii2-php-file-cache:^2.0"
```

or add

```
"sergeymakinen/yii2-php-file-cache": "^2.0"
```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Set the following Yii 2 configuration parameters:

```
[
    'components' => [
        'phpCache' => [
            'class' => 'sergeymakinen\yii\phpfilecache\Cache',
        ],
    ],
]
```

And you can use it like any Yii 2 cache class:

```
Yii::$app->phpCache->set('foo', 'bar')
```

### Caching values with a PHP code

[](#caching-values-with-a-php-code)

If you need to execute any PHP bootstrap code before you get a value from a cache, pass a `sergeymakinen\yii\phpfilecache\ValueWithBootstrap` instance with the value and a PHP code (which can be multiline of course) as a string to `set()`:

```
use sergeymakinen\yii\phpfilecache\ValueWithBootstrap;

Yii::$app->phpCache->set(
    'foo',
    new ValueWithBootstrap(
        'bar',
        'Yii::$app->params[\'fromCache\'] = true;'
    )
);
```

Since version 1.1 you can also pass a `Closure` instead of a PHP code:

```
use sergeymakinen\yii\phpfilecache\ValueWithBootstrap;
use yii\helpers\StringHelper;

Yii::$app->phpCache->set(
    'foo',
    new ValueWithBootstrap('bar', function () {
        \Yii::$app->params['fromCache'] = true;
        \Yii::$app->params['name'] = StringHelper::basename('/etc/config');
    })
)
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 94.7% 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.

###  Release Activity

Cadence

Every ~141 days

Total

4

Last Release

3059d ago

Major Versions

v1.1.0 → v2.0.02017-01-06

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/983964?v=4)[Sergey Makinen](/maintainers/sergeymakinen)[@sergeymakinen](https://github.com/sergeymakinen)

---

Top Contributors

[![sergeymakinen](https://avatars.githubusercontent.com/u/983964?v=4)](https://github.com/sergeymakinen "sergeymakinen (18 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

bootstrapcachecachingfilephpphp-libraryyii2yii2-extensionphpcachecachingfileyii2yiiyii2-php-file-cache

### Embed Badge

![Health badge](/badges/sergeymakinen-yii2-php-file-cache/health.svg)

```
[![Health](https://phpackages.com/badges/sergeymakinen-yii2-php-file-cache/health.svg)](https://phpackages.com/packages/sergeymakinen-yii2-php-file-cache)
```

###  Alternatives

[alekseykorzun/memcached-wrapper-php

Optimized PHP 5 wrapper for Memcached extension that supports dog-piling, igbinary and local storage

2887.3k1](/packages/alekseykorzun-memcached-wrapper-php)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15194.2k7](/packages/rapidwebltd-rw-file-cache)

PHPackages © 2026

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