PHPackages                             longitude-one/settings-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. longitude-one/settings-bundle

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

longitude-one/settings-bundle
=============================

A bundle to retrieve settings of your application.

04PHP

Since Nov 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/longitude-one/settings-bundle)[ Packagist](https://packagist.org/packages/longitude-one/settings-bundle)[ RSS](/packages/longitude-one-settings-bundle/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

settings-bundle
===============

[](#settings-bundle)

Settings bundle for Symfony 5.1+ and PHP 7.4+

How to install it on Symfony 5.1+ application
---------------------------------------------

[](#how-to-install-it-on-symfony-51-application)

First of all, we will need a symfony 5.1 startup application, let's say [symfony-standard edition with composer](https://symfony.com/doc/current/best_practices/creating-the-project.html)

- `composer create-project symfony/skeleton [project name]`

Now let's add the **longitude-one/settings-bundle**

You can find the doctrine-extensions project on packagist:

To add it to your project:

- `composer require longitude-one/settings-bundle`

How to map it on Symfony 5.1+ application
-----------------------------------------

[](#how-to-map-it-on-symfony-51-application)

Let's start from the mapping. You will need to map this classes for your ORM to be aware of. To do so, add some mapping info to your doctrine.orm configuration, edit `config/packages/doctrine.yaml`:

```
doctrine:
    dbal:
# your dbal config here

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true
# only these lines are added additionally
        mappings:
            settings:
                type: annotation
                alias: Settings
                prefix: LongitudeOne\SettingsBundle\Entity
                # make sure vendor library location is correct
                dir: "%kernel.project_dir%/vendor/longitude-one/settings-bundle/src/LongitudeOne/Entity"
```

After that, running `symfony console doctrine:mapping:info` you should see the output:

```
 Found xx mapped entities:

 [OK]   App\Entity\... #Entities of your own entities
 ...
 [OK]   LongitudeOne\SettingsBundle\Entity\Settings

```

How to use the settings in your application?
--------------------------------------------

[](#how-to-use-the-settings-in-your-application)

### How to create a settings?

[](#how-to-create-a-settings)

You only have to create an object and to persist it.

```
namespace App\Controller;

use Doctrine\ORM\EntityManagerInterface;use LongitudeOne\SettingsBundle\Entity\Settings;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class FooController  extends AbstractController
{
    public function create(EntityManagerInterface $entityManager)
    {
        $bar = '42'; //$bar can be an array, an object or anything that can be serialized.
        $settings = new Settings();
        $settings->setCode('foo');
        $settings->setValue($bar);

        $entityManager->persist($settings);
        $entityManager->flush();
    }
}
```

### How to retrieve a value in a controller

[](#how-to-retrieve-a-value-in-a-controller)

First, you need to add the directory of this bundle to the list of Symfony's autowired services. Edit `config/services.yaml`:

```
# these lines are the default one
parameters:

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'
            - '../src/Tests/'

# only the below lines are added
    LongitudeOne\SettingsBundle\:
        resource: '../vendor/longitude-one/settings-bundle/src/LongitudeOne/'
        exclude:
            - '../vendor/longitude-one/settings-bundle/src/LongitudeOne/Entity/'
            - '../vendor/longitude-one/settings-bundle/src/LongitudeOne/Exception/'
```

Now you're able to call the settings interface in your own controller and in your own services:

```
namespace App\Controller;

use LongitudeOne\SettingsBundle\Service\SettingsInterface;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class FooController  extends AbstractController
{
    public function getValue(SettingsInterface $settingsManager)
    {
        $value = $settingsManager->getValue('foo');
        //...
    }
}
```

If the `foo` settings doesn't exist, a SettingsException will be thrown.

### How to retrieve a value in a service

[](#how-to-retrieve-a-value-in-a-service)

First, you need to add the directory of this bundle to the list of Symfony's autowired services. The previous paragraph explain how to do it.

Now, you can use the dependency injection abilities in your services.

```
namespace App\Service;

use LongitudeOne\SettingsBundle\Service\SettingsInterface;

class FooService
{
    private SettingsInterface $settings;

    public function __construct(SettingsInterface $settings) {
        $this->settings=$settings;
    }

    public function someMethod()
    {
        //...
        $value = $this->settings->getValue('foo');
        //...
    }
}
```

If the `foo` settings doesn't exist, a SettingsException will be thrown.

### How to retrieve a value in a twig template

[](#how-to-retrieve-a-value-in-a-twig-template)

First, you need to add the directory of this bundle to the list of Symfony's autowired services. The previous paragraph explain how to do it.

Now, you can use the `settings` filter and the `settings` function to retrieve your application settings.

```
    {{ dump('foo'|settings) }}

    {{ dump(settings('foo')) }}
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5101481?v=4)[Alexandre Tranchant](/maintainers/Alexandre-T)[@Alexandre-T](https://github.com/Alexandre-T)

---

Top Contributors

[![Alexandre-T](https://avatars.githubusercontent.com/u/5101481?v=4)](https://github.com/Alexandre-T "Alexandre-T (12 commits)")

### Embed Badge

![Health badge](/badges/longitude-one-settings-bundle/health.svg)

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

###  Alternatives

[askvortsov/flarum-auto-moderator

Powerful automation engine.

1418.4k2](/packages/askvortsov-flarum-auto-moderator)

PHPackages © 2026

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