Metadata Bundle

Metadata bundle integrates the Metadata component into Symfony applications by providing a service to read metadata using PHP attributes.

Installation

You can install the bundle using Composer:

composer require runopencode/metadata-bundle

And then enable the bundle in your Symfony application:

1<?php
2
3// config/bundles.php
4
5return [
6    // ...
7    RunOpenCode\MetadataBundle\MetadataBundle::class => ['all' => true],
8];

Configuration

The bundle provides you with a possibility to configure cache driver for metadata reader service. By default, it uses in-memory array cache for dev and test environments. For prod environment, it uses Symfony’s system.cache cache pool. You may override this behavior by configuring the bundle as shown below.

However, do note that your cache pool is always ignored in dev and test environments and only in-memory caching is used instead.

1<?php
2// config/packages/runopencode-metadata.php
3use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
4
5return static function (ContainerConfigurator $container): void {
6    $container->extension('runopencode_metadata', [
7        'cache_pool' => 'cache.adapter.filesystem',
8    ]);
9};
1# config/packages/runopencode-metadata.yaml
2runopencode_metadata:
3    cache_pool: cache.adapter.filesystem

Usage

Once the bundle is installed and configured, you can use the metadata reader service in your Symfony application. The service is available via dependency injection using the \RunOpenCode\Component\Metadata\Contract\ReaderInterface.

Read more about how to use the metadata reader in the Metadata component.