Giter Club home page Giter Club logo

rchconfigaccessbundle's Introduction

RCHConfigAccessBundle

Build Status StyleCI SensioLabsInsight

Retrieve final configuration values from any container-aware context.

Why?

In Symfony, when you need to get the value of any configuration (default in app/config) the answer is always parameters.

But, what about the final configuration? After that the DI container has been compiled? After that compiler passes and bundle extensions changed it or merged it with a default one?

Actuall there is no solution excepted processing the whole configuration of a bundle each time you need it, even partially. This bundle is intended to solve this problem.

Related issues:

Installation

Download the bundle

$ composer require rch/config-access-bundle

This command requires you to have Composer installed globally.

Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

// app/AppKernel.php

$bundles = array(
    // ...
    new RCH\ConfigAccessBundle\RCHConfigAccessBundle(),
);

Usage

Get configuration values

<?php

$accessor = $this->container->get('rch.config_access.accessor');

$accessor->get('security');
// array('encoders' => array(...), 'providers' => array(...), ...)

$accessor->get('framework.serializer');
// array('enabled' => true, ...)

$accessor->get('framework.serializer.enabled');
// true

$accessor->get('stof_doctrine_extensions.uploadable');
// array('orm' => array(...), 'uploadable' => array(...), ...)

$accessor->get('lexik_jwt_authentication.encoder.service'); 
// 'lexik_jwt_authentication.encoder.default'

$accessor->get('frameorf.default_locale'); 
$accessor->get('framework.default_loal');

// Did you mean "framework.default_locale"?

Inject them into your services

services:
    foo_manager:
        arguments: 
            - '@=service("rch_config_access.accessor").get("security")'
<?php

namespace AppBundle\Services;

class FooManager 
{
    public function __construct(array $security)
    {
        $this->security = $security;
    }
    
    // ...
}

Contributing

Guidelines

License

The code is released under the MIT license.

For the whole copyright, see the distributed LICENSE file.

rchconfigaccessbundle's People

Contributors

chalasr avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wingsergey

rchconfigaccessbundle's Issues

[Insight] The Symfony Dependency Injection Container should not be passed as argument

in Config/Accessor.php, line 56

A Symfony dependency injection container has been found as an argument.

    /**
     * @param ContainerInterface     $container
     * @param Bundle[]               $bundles
     * @param CacheItemPoolInterface $cache
     */
    public function __construct(ContainerInterface $container, array $bundles, CacheItemPoolInterface $cache)
    {
        $this->container = $container;
        $this->bundles = $bundles;
        $this->cache = $cache;
    }

Posted from SensioLabsInsight

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.