Git Product home page Git Product logo

classmetabundle's Introduction

Class Meta Bundle

Symfony bundle for my Class Meta library. This allows you to attach arbitrary metadata to classes and their constants via annotation.

Installation

To install via composer, use the following command:

$ composer require ashleydawson/class-meta-bundle

And then add the bundle to the AppKernel#registerBundles() method:

$bundles = [
    // ...
    new AshleyDawson\ClassMetaBundle\AshleyDawsonClassMetaBundle(),
];

Configuration

Configuration allows you to set a cache provider. By default the cache provider is ArrayCache - so in production, I'd advise you change this to a more persistent cache strategy:

# app/config/config.yml

services:
    my_class_meta_cache_provider:
        class: Doctrine\Common\Cache\FilesystemCache
        arguments: [ "%kernel.cache_dir%/ashleydawson/class_meta" ]

ashley_dawson_class_meta:
    cache_provider_service_id: my_class_meta_cache_provider # Cache provider service ID (optional)
    cache_provider_ttl: 300 # 5 minutes TTL (optional)

Note: The cache is invalidated by file modify time, but if you want to also add a TTL (Time-to-live) to the cache it can be done via the cache_provider_ttl parameter.

Note: To disable the cache, simply pass the id of a Doctrine\Common\Cache\VoidCache service.

Basic Usage

To use the meta cache manager service in a controller, simply do:

public function indexAction()
{
    $meta = $this->get('ashleydawson.class_meta')->getClassConstantsMeta('AppBundle\Enum\MyEnum');
    
    dump($meta);
}

For more documentation, please see the full library readme.

classmetabundle's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.