PHPackages                             webfactory/wfdmeta-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. webfactory/wfdmeta-bundle

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

webfactory/wfdmeta-bundle
=========================

Bundle to query the wfd\_meta table and use it for ConfigCache expiry. Useful as example code, please see the README file.

4.5.1(4mo ago)432.4k↓11.1%[2 issues](https://github.com/webfactory/WebfactoryWfdMetaBundle/issues)MITPHPPHP &gt;= 8.1CI passing

Since Jul 3Pushed 4mo ago5 watchersCompare

[ Source](https://github.com/webfactory/WebfactoryWfdMetaBundle)[ Packagist](https://packagist.org/packages/webfactory/wfdmeta-bundle)[ RSS](/packages/webfactory-wfdmeta-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (21)Versions (92)Used By (0)

WebfactoryWfdMetaBundle
=======================

[](#webfactorywfdmetabundle)

What is this cruft?
-------------------

[](#what-is-this-cruft)

This bundle provides services and tools to work with content metadata as tracked by the [wfDynamic Content Management System](http://www.wfdynamic.de). This data is kept in a database table named `wfd_meta`. Among other things, it holds timestamps for creation, last update and possibly deletion of all managed records.

We have open-sourced it less for direct usage: You probably don't have the necessary information readily available in the format required by this bundle.

We rather found it might be useful for others thinking about a similar solution. Especially using a custom `ConfigCacheFactory` implementation, custom database-aware resources and the annotation to make `Controller` results cacheable might be interesting examples how you can hook into details of the [Symfony Framework](http://www.symfony.com) to implement more specialized features.

Services and APIs exposed by this bundle
----------------------------------------

[](#services-and-apis-exposed-by-this-bundle)

The following sections try to describe those parts of the bundle meant to serve as the public API. Everything else should be considered the moving parts you are not supposed to interfere with.

### `webfactory_wfd_meta.provider` service

[](#webfactory_wfd_metaprovider-service)

An instance of `\Webfactory\Bundle\WfdMetaBundle\Provider` that can be used to query the timestamp of the last change (change or deletion) in one or several tables identified by their table names or wfDynamic table IDs. Can also be used to query this information for a single database row.

The special table name `*` denotes "any change/table".

### The `\Webfactory\Bundle\WfdMetaBundle\MetaQuery` class

[](#the-webfactorybundlewfdmetabundlemetaquery-class)

Use a `MetaQuery` to separate concerns when the code that knows *what* changes to track is distributed and/or different from the code acting upon that information. More precisely, one or several clients can call the `MetaQuery` to add the Doctrine entity instance, entity class, database table name or wfDynamic table IDs to track for changes. Then, the query can be passed along and eventually be executed. Again, the special tablename `*` denotes "any table".

Either create a `MetaQuery` instance for a particular purpose as a DIC service; you can inherit from the abstract `webfactory_wfd_meta.meta_query` service to do so. Alternatively, call the `create()` method on the `webfactory_wfd_meta.meta_query_factory` service.

### HTTP cache validation based on `wfd_meta` data

[](#http-cache-validation-based-on-wfd_meta-data)

The Send304IfNotModified annotation is deprecated as we wanted to allow the combination of multiple "ressource watchers" - e.g. one watching wfdMeta data, one watching non-wfd-meta-tracked data and one watching e.g. the date (for resetting at a certain date).

Additionally, we wanted to inverse the dependency direction: a caching bundle should be able to make use of the wfdMetaBundle (and many others), but the wfdMetaBundle should not take care about caching.

This resulted in the concept of "Last Modified Determinators" in the new [WebfactoryHttpCacheBundle](https://github.com/webfactory/WebfactoryHttpCacheBundle).

You can quickly convert deprecated Send304IfNotModified annotations to a LastModifiedDeterminator by using [WfdMetaQueries](src/Caching/WfdMetaQueries.php) . This conversion does not fully embrace the concept of LastModifiedDeterminators (especially not when using resetInterval; see the bundle's readme), but if you're in a hurry, maybe you don't want to be bothered with that.

#### Using a `resetInterval`

[](#using-a-resetinterval)

The annotation features an additional setting named `resetInterval` with defaults to 2419200 seconds (28 days).

The `Last-Modified` header added by the annotation will be shifted to the nearest (past) multiple of this value. This effectively makes the response never seem older than the given interval and has the net effect of expiring the cache (and re-running the controller once) after this interval has expired, even when no change has been recorded in `wfd_meta`.

This can come in handy when you know that your response depends on data that can be tracked via `wfd_meta`, but it also includes (computed) elements that change over time. For example, set `resetInterval` to `3600` to regenerate the response every hour, use a cached response as long as possible but also immediately re-generate the response when `wfd_meta` tracks a change.

### `webfactory_wfd_meta.controller.template:templateAction` controller-as-a-service

[](#webfactory_wfd_metacontrollertemplatetemplateaction-controller-as-a-service)

Just like the [FrameworkBundle:Template-Controller](http://symfony.com/doc/current/cookbook/templating/render_without_controller.html), this can be used to render arbitrary Twig templates that do not need any additional controller for processing. But, in addition to the basic caching properties, `wfd_meta` settings and change tracking can be added. Here's an example:

```
# routing.yml
# At /demo, render the MyBundle:Foo:bar.html.twig template. Keep the response in public caches, revalidating it every 10s. Whenever wfd_meta tracks any change, generate a fresh response.
demo:
    path: /demo
    defaults:
        _controller:  webfactory_wfd_meta.controller.template:templateAction
        template:     'MyBundle:Foo:bar.html.twig'
        sharedAge:    10
        metaTables:   *
```

### The `\Webfactory\Bundle\WfdMetaBundle\Util\CriticalSection` utility class

[](#the-webfactorybundlewfdmetabundleutilcriticalsection-utility-class)

This class implements a [critical section](https://en.wikipedia.org/wiki/Critical_section). Use it whenever two processes (on the same machine/host) do possibly interfering stuff or attempt to do the same thing. The critical section will give one process way and block the others until the first one has finished its task.

### A custom `ConfigCacheFactory` implementation and specialized resource types

[](#a-custom-configcachefactory-implementation-and-specialized-resource-types)

In the full-stack Symfony framework, several components use the `ConfigCache` mechanism to cache expensive-to-generate things. This includes translation catalogues as well as the URL router and matcher components.

This bundle adds two new types of resources, `\Webfactory\Bundle\WfdMetaBundle\Config\DoctrineEntityClassResource` and `\Webfactory\Bundle\WfdMetaBundle\Config\WfdTableResource`. Add instances of those resources to classes like the `MessageCatalogue` (translation component) or the `RouteCollection` (routing component) when you generate translations or routes based on database content.

This bundle will replace, or more precisely: decorate, the `config_cache_factory` service implementation. It will include a check for those new resource types and make sure that the cache will be refreshed whenever a relevant change is tracked in `wfd_meta`. This will *also happen in `kernel.debug = false`*, i. e. in production mode!

The `CriticalSection` will be used to make sure only one process at a time tries to re-create the cache, while others wait and re-use the result.

Configuration
-------------

[](#configuration)

This bundle has a single configuration setting:

```
# config_test.yml
webfactory_wfd_meta:
    always_expire_wfd_meta_resources: true
```

With this setting, ConfigCache instances (Symfony Router, Translator, ... maybe?) that include WfdMetaResource instances will expire immediately.

This is helpful e. g. in functional tests, where you have database-backed routes, translations or similar: You can change the database values and no longer need to think about the ConfigCaches or poke wfd\_meta to make the changes effective.

Tests
-----

[](#tests)

Run the tests with

```
vendor/bin/phpunit

```

Credits, Copyright and License
------------------------------

[](#credits-copyright-and-license)

This project was started at webfactory GmbH, Bonn.

-
-

Copyright 2015-2023 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance64

Regular maintenance activity

Popularity32

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 61% 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 ~55 days

Recently: every ~7 days

Total

90

Last Release

146d ago

Major Versions

2.6.0 → 3.0.02017-05-15

3.19.1 → 4.0.12024-03-28

3.19.2 → 4.0.22024-03-30

3.19.3 → 4.0.32024-05-15

3.19.x-dev → 4.0.42024-07-01

PHP version history (7 changes)2.5.1PHP ^5.5.0 | ^7.0.0

3.5.0PHP ^5.5.0 || ^7.0.0

3.6.0PHP ^5.5.0|^7.0

3.7.0PHP ^7.2

3.10.0PHP ^7.2|8.0.\*|8.1.\*

3.18.0PHP &gt;= 7.2, &lt; 8.4

4.0.1PHP &gt;= 8.1

### Community

Maintainers

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

---

Top Contributors

[![mpdude](https://avatars.githubusercontent.com/u/1202333?v=4)](https://github.com/mpdude "mpdude (86 commits)")[![MalteWunsch](https://avatars.githubusercontent.com/u/2504942?v=4)](https://github.com/MalteWunsch "MalteWunsch (41 commits)")[![relthyg](https://avatars.githubusercontent.com/u/8628559?v=4)](https://github.com/relthyg "relthyg (9 commits)")[![FabianSchmick](https://avatars.githubusercontent.com/u/17527958?v=4)](https://github.com/FabianSchmick "FabianSchmick (2 commits)")[![MatthiasMolitor](https://avatars.githubusercontent.com/u/1383323?v=4)](https://github.com/MatthiasMolitor "MatthiasMolitor (2 commits)")[![sebastiankugler](https://avatars.githubusercontent.com/u/4364200?v=4)](https://github.com/sebastiankugler "sebastiankugler (1 commits)")

---

Tags

bundlesymfony

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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