PHPackages                             phpfastcache/phpfastcache-bundle - 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. phpfastcache/phpfastcache-bundle

AbandonedArchivedSymfony-bundle[Caching](/categories/caching)

phpfastcache/phpfastcache-bundle
================================

Phpfastcache Bundle for Symfony integration

3.0.0(7y ago)1834.3k↓100%2MITPHPPHP ^7.0

Since May 15Pushed 7y ago3 watchersCompare

[ Source](https://github.com/PHPSocialNetwork/phpfastcache-bundle)[ Packagist](https://packagist.org/packages/phpfastcache/phpfastcache-bundle)[ Docs](http://www.phpfastcache.com)[ RSS](/packages/phpfastcache-phpfastcache-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (13)Versions (27)Used By (0)

[![Code Climate](https://camo.githubusercontent.com/c6f2d285914ecd687ca9f24c21a8f0357717882fb89362268c06fe24b242642c/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f504850536f6369616c4e6574776f726b2f7068706661737463616368652d62756e646c652f6261646765732f6770612e737667)](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache-bundle) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/a42971904e16794f420e307efb0682b521d768c5ebcb520bee70bad0842344e7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f504850536f6369616c4e6574776f726b2f7068706661737463616368652d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache-bundle/?branch=master) [![Build Status](https://camo.githubusercontent.com/ddc88184a3dee8432d045fe4b31eb85460a7a56a60abd4c52d3a9333a2b12f07/68747470733a2f2f7472617669732d63692e6f72672f504850536f6369616c4e6574776f726b2f7068706661737463616368652d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/PHPSocialNetwork/phpfastcache-bundle) [![Latest Stable Version](https://camo.githubusercontent.com/ad6d90fc6b0e0904b7dfa5a72fa575ff91f5e2581d65bb92a0a6b7be7c58207c/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706661737463616368652f7068706661737463616368652d62756e646c652e737667)](https://packagist.org/packages/phpfastcache/phpfastcache-bundle) [![Total Downloads](https://camo.githubusercontent.com/e193ef09a23e93ca99e64f914ff500d5a1f93cabc346888c8d9772b9feb42617/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068706661737463616368652f7068706661737463616368652d62756e646c652e737667)](https://packagist.org/packages/phpfastcache/phpfastcache-bundle) [![License](https://camo.githubusercontent.com/520dab27ef6c7f6f532c2efcb6dc3a4fd4889fe89bd8cea98c37d3b153fd1d6d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068706661737463616368652f7068706661737463616368652d62756e646c652e737667)](https://packagist.org/packages/phpfastcache/phpfastcache-bundle)

Symfony Flex PhpFastCache Bundle
================================

[](#symfony-flex-phpfastcache-bundle)

#### ⚠️ Please note that the V3 is a major (BC breaking) update of the PhpFastCache Bundle !

[](#warning-please-note-that-the-v3-is-a-major-bc-breaking-update-of-the-phpfastcache-bundle-)

> As of the V3 the bundle is **absolutely** not compatible with previous versions.
> To ensure you the smoothest migration possible, please check the migration guide in the Resources/Docs directory.
> One of the biggest change is the Phpfastcache's dependency which is not set to the v7 which it not backward compatible at all.

#### 👍 Step 1: Include phpFastCache Bundle in your project with composer:

[](#thumbsup-step-1-include-phpfastcache-bundle-in-your-project-with-composer)

```
composer require phpfastcache/phpfastcache-bundle
```

#### 🚧 Step 2: Setup your `config/packages/phpfastcache.yaml` to configure your cache(s) instance(s)

[](#construction-step-2-setup-your-configpackagesphpfastcacheyaml-to-configure-your-caches-instances)

```
# PhpFastCache configuration
phpfastcache:
    twig_driver: "filecache" # This option must be a valid declared driver, in our example: "filecache"
    twig_block_debug: false # This option will wrap CACHE/ENDCACHE blocks with block debug as HTML comment
    drivers:
        filecache:
            type: Files
            parameters:
                path: "%kernel.cache_dir%/phpfastcache/"
```

- This step can be skipped using [Symfony recipes](https://symfony.com/doc/current/setup/flex.html).

#### 🚀 Step 3: Accelerate your app by making use of PhpFastCache service

[](#rocket-step-3-accelerate-your-app-by-making-use-of-phpfastcache-service)

Caching data in your controller:

```
public function indexAction(Request $request, Phpfastcache $phpfastcache)
{
    $cache = $phpfastcache->get('filecache');
    $item = $cache->getItem('myAppData');

    if (!$item->isHit() || $item->get() === null) {
        $item->set('Wy app has now superpowers !!')->expiresAfter(3600);//1 hour
        $cache->save($item);
    }

    // replace this example code with whatever you need
    return $this->render('default/index.html.twig', [
        'myAppData' => $item->get(),
        'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'),
    ]);
}
```

Or in your template:

```

    {#
     * 'myrandom6' Is your cache key identifier, must be unique
     * 300 Is the time to live (TTL) before the cache expires and get regenerated
    #}
    {% cache 'myrandom6' 300 %}

            {% for i in 1..1000 %}{{ random() }}{% endfor %}

    {% endcache %}

```

#### 💻 CLI command interactions

[](#computer-cli-command-interactions)

As of the V3, some command-line tools were introduced, mostly for CRUD-like operations.

##### GET operation

[](#get-operation)

```
php bin/console phpfastcache:get filecache cacheKey
```

This will display the content of a cache item if it eventually exists.

##### SET operation

[](#set-operation)

```
php bin/console phpfastcache:get filecache cacheKey '{"a": 14}' 300 -a 1
```

This will set the content of a cache item.
The TTL (300), in seconds, is optional and take the default value filled in your configuration file.
The `auto-type-cast` option *"-a"* (enabled by default) will let allows you to automatically type cast your variable:

- `false` and `true` will be respectively converted to *boolean*.
- `1337` and `1337.666` will be respectively be converted to *integer* or *float*.
- `null` will be converted to *null*.
- `{"a": 14}` will be converted to an associative *array* using a JSON detection
- `a regular string` will remains unchanged and stays a string

You can obviously disable this behavior by turning off the `auto-type-cast` option: `-a 0`

##### DELETE operation

[](#delete-operation)

```
php bin/console phpfastcache:del filecache cacheKey
```

This will delete the specified cache item.

##### CLEAR operation

[](#clear-operation)

```
php bin/console phpfastcache:clear filecache
# OR to clear every caches:
php bin/console phpfastcache:clear
```

This will clear a single cache instance if specified or all the configured cache instances otherwise.

#### 💡 Introducing Cacheable Responses (V3 only)

[](#bulb-introducing-cacheable-responses-v3-only)

As of the V3 there's a new, easier and cleaner way to setup HTTP cache to decrease your server bandwidth along with your CPU load: Cacheable Responses. And it's pretty easy to implement:

```
    /**
     * @Route("/cached", name="cached")
     */
    public function cachedAction(Phpfastcache $phpfastcache, Request $request): Response
    {
        return (new CacheableResponse($phpfastcache->get('filecache'), $request))->getResponse('cache_key', 3600, function () {
            return new Response('Random bytes: ' . \random_bytes(255));
        });
    }
```

`CacheableResponse` is provided by `\Phpfastcache\Bundle\Response\CacheableResponse`. This class will handle responses headers (cache-control, etag, etc...) and http status (304 Not modified).

#### 💥 phpFastCache Bundle support

[](#boom-phpfastcache-bundle-support)

Found an issue or had an idea ? Come here [here](https://github.com/PHPSocialNetwork/phpfastcache-bundle/issues) and let us know !

###  Health Score

37

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 86.8% 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 ~29 days

Recently: every ~4 days

Total

26

Last Release

2855d ago

Major Versions

1.0.0 → 2.0.0-alpha2016-08-20

1.0.3 → 2.0.0-beta22016-12-07

1.0.4 → 2.0.02017-07-01

1.0.5 → 2.0.32018-05-01

2.x-dev → 3.0.0-alpha2018-05-08

PHP version history (2 changes)2.0.0-betaPHP ^5.6 || ^7.0

3.0.0-alpha2PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b65bc1fa88977daa7b95d017fe3e4f34e8db0fdbb48d20a658da95bd34e82aaa?d=identicon)[khoaofgod](/maintainers/khoaofgod)

![](https://www.gravatar.com/avatar/8827eab6b94ffc33a593361980485749ed729a4d3a7bca2c9a9f3bddc7cf68f1?d=identicon)[Geolim4](/maintainers/Geolim4)

---

Top Contributors

[![Geolim4](https://avatars.githubusercontent.com/u/1332071?v=4)](https://github.com/Geolim4 "Geolim4 (132 commits)")[![PastisD](https://avatars.githubusercontent.com/u/442023?v=4)](https://github.com/PastisD "PastisD (20 commits)")

---

Tags

cacheable-responsesflex-bundlephpfastcache-bundlephpfastcache-servicesymfony-bundlesymfony-cachephpsymfonybundlecachephpfastcache

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpfastcache-phpfastcache-bundle/health.svg)

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

###  Alternatives

[harmbandstra/swagger-ui-bundle

Exposes swagger UI inside your Symfony project through a route (eg. /docs)

42860.5k](/packages/harmbandstra-swagger-ui-bundle)[symfony-bundles/redis-bundle

Symfony Redis Bundle

271.1M5](/packages/symfony-bundles-redis-bundle)[incenteev/hashed-asset-bundle

Apply an asset version based on a hash of the asset for symfony/asset

25521.0k1](/packages/incenteev-hashed-asset-bundle)[inspector-apm/inspector-symfony

Code Execution Monitoring for Symfony applications.

2828.1k1](/packages/inspector-apm-inspector-symfony)

PHPackages © 2026

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