Download the PHP package helis/settings-manager-bundle without Composer

On this page you can find all versions of the php package helis/settings-manager-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package settings-manager-bundle

Helis Settings Manager Bundle

Provides a nice way to define variables and inject them into application parts.

Latest Stable Version License

Jump to

Quick start

  1. composer require helis/settings-manager-bundle

  2. Register bundle to AppKernel.php (Symfony3) or config/bundles.php (Symfony4)

  3. Add an example configuration to app/config/config.yml (Symfony3) or config/packages/settings_manager.yaml (Symfony4)

  4. Now, the easiest way to get settings in your services is by using SettingsRouterAwareTrait. The service will be automatically injected by autowire. Then just ask for setting:

Usage

To get settings into your services, you have a few choices:

SettingsRouter

SettingsRouter is pretty straight-forward. It has one main method, called $settingsRouter->get($settingName, $default = null), which returns a setting of any type. If the setting is missing, default value will be returned. Other getters are aliases for get but with declared return types and appropriate default values.

Method name Default value Declared return type
getString '' string
getBool false bool
getInt 0 int
getFloat 0.0 float
getArray [] array

Throw exception on miss

In some cases throwing exception if setting not found might be desired behaviour. For this purpose, SettingsRouter has mustGet($settingName) and mustGet...($settingName) for each aliased getter.

Method name Declared return type
mustGetString string
mustGetBool bool
mustGetInt int
mustGetFloat float
mustGetArray array

Service Tag

If you don't want to inject SettingsRouter or wish for a cleaner service, service tags are here to help. First of all, the service must have a setter, which can be used to inject a setting value. For bool values, the bundle provides the SwitchableTrait, which adds setEnabled and isEnabled methods. Then add a tag on your service with attributes setting for setting name and method for method name. Example:

or the must version

Models

Helis\SettingsManagerBundle\Model\SettingModel

Base setting model.

Property Type Description
$name string Setting name
$description string Setting descrption
$domain DomainModel Domain model
$tags Collection[Tag] Collection of tags
$type Enum[Type] Determines setting value type
$data array Holds actual value for setting
$providerName string Internal field to know from which provider this setting is

Helis\SettingsManagerBundle\Model\DomainModel

Domain is like a group for settings. Setting cannot exist without domain. The default is named default, which is also always enabled. Domain can hold only one setting with the same name. Settings with the same names must be in different domains. When a setting is requested, the one from a higher priority domain will be returned.

Property Type Description
$name string Domain name
$priority int (default: 0) Domain priority
$enabled bool (default: false) Is domain enabled indication
$readOnly bool (default: false) is domain only readable indication

Helis\SettingsManagerBundle\Model\Type

Enum which holds supported types for setting. Values:

Setting providers

Settings can be pulled from multiple sources. Currently, the bundle comes with 4 settings providers. They can be configured and prioritized. If a setting with the same name will come from >1 providers, setting from provider with higher priority will override settings from lower priority providers.

Settings can be easily mutated in providers using user interface.

Settings providers:

And additional decorating providers:

Simple settings provider

Helis\SettingsManagerBundle\Provider\SimpleSettingsProvider

This is a provider, which only holds settings collections. Currently, it's being used to hold settings from configuration, but many more can be configured.

To configure additional simple providers, factory is provided because provider can only accept already denormalized objects.

Configuration example:

DoctrineORM settings provider

Helis\SettingsManagerBundle\Provider\DoctrineOrmSettingsProvider

This is a provider which reads and saves settings using EntityManagerInterface.

Required libraries:

composer require doctrine/orm

Configuration example:

  1. Doctrine configuration

  2. Create setting entity

  3. Update your doctrine schema.

  4. Register settings provider:

Paseto cookie settings provider

Helis\SettingsManagerBundle\Provider\PasetoCookieSettingsProvider

This is a provider, which only enables existing settings by using a cookie. Cookies are encoded, so that they could not be randomly enabled by users.

Required libraries:

Asymmetric Paseto cookie settings provider

Helis\SettingsManagerBundle\Provider\AsymmetricPasetoCookieSettingsProvider

This is a provider, which only enables existing settings by using a cookie. Cookies are encoded with asymmetric private and public keys, so that they could not be randomly enabled by users.

Required libraries:

JWT Cookie settings provider

Helis\SettingsManagerBundle\Provider\JwtCookieSettingsProvider

This is a provider, which only enables existing settings by using a cookie. Cookies are encoded with asymmetric private and public keys, so that they could not be randomly enabled by users.

Required libraries:

AWS SSM settings provider

Helis\SettingsManagerBundle\Provider\AwsSsmSettingsProvider

This is a provider, which is used only for reading and updating existing ssm parameters as settings.

Required libraries:

Configuration example:

Phpredis decorating settings provider

Helis\SettingsManagerBundle\Provider\DecoratingRedisSettingsProvider

This provider is used to cache other settings providers like symfony/cache adapters because we want to take advantage of redis data structures for simplier invalidation process.

Required extensions:

Configuration example:

Predis decorating settings provider

Helis\SettingsManagerBundle\Provider\DecoratingPredisSettingsProvider

Same as predis.

Required libraries:

Cache decorating provider

Helis\SettingsManagerBundle\Provider\DecoratingCacheSettingsProvider

This provider is used to cache other settings providers that implements ModificationAwareSettingsProviderInterface. At the moment supports PHP Files Cache Adapter. Single change in decorating provider causes whole cache to be invalidated. Supports symfony cache component adapters

Required libraries and extensions:

composer require symfony/cache symfony/lock

Configuration example:

Settings provider mock

This is a special provider supposed to be used in tests only. Useful, when there is a need to mock mustGet... calls.

Configuration example:

Mocking:

Configuration reference

User interface

User interface can be used to change setting values, enable or disable domains.

  1. Bundled user interface requires knp-menu-bundle, jsrouting-bundle.

    composer require symfony/form symfony/validator symfony/translation symfony/twig-bundle symfony/asset knplabs/knp-menu-bundle friendsofsymfony/jsrouting-bundle

  2. Include routing file.

That's it. Now go to the /settings path and you will see the settings user interface.

Twig

The Twig extension is also added to get settings in your twig templates. Just like in SettingsRouter, first argument is the setting name and the second sets default value.

Controller

Helis\SettingsManagerBundle\Controller\Traits\SettingsControllerTrait

Adds a method to deny access, unless a setting is enabled. It's using SettingsRouter, which, again, will be injected by autowire.

Contribution

New feature branches should be created from the master branch.


All versions of settings-manager-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
doctrine/collections Version ^1.5
symfony/config Version ^5.4|^6.3
symfony/console Version ^5.4|^6.3
symfony/dependency-injection Version ^5.4|^6.3
symfony/http-kernel Version ^5.4|^6.3
symfony/serializer Version ^5.4|^6.3
symfony/yaml Version ^5.4|^6.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package helis/settings-manager-bundle contains the following files

Loading the files please wait ....