Download the PHP package effiana/config-bundle without Composer

On this page you can find all versions of the php package effiana/config-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 config-bundle

Information

Build Status Coverage Status

ConfigBundle manages configuration settings stored in the database and makes them accessible via a service in your Symfony project. These settings are similar to those defined in parameters.yml but can be modified at runtime, e.g. by an admin user.

Installation

Get the bundle

Let Composer download and install the bundle by running

in a shell.

Enable the bundle

Create the table

Preferably you do this by calling

or

or however you like.

Add the route to manage settings (optional)

You can either import the default routing configuration

...or add your own to have full control over the URL pattern.

Some CSS is needed to render the form correctly. Install the assets in your project:

Usage

Defining settings

This bundle does not provide functionality to create new settings because this would make no sense at runtime. Those settings will be used in your application and thus code needs to be written for that. This means that you have to create new settings in the database table effiana_config_setting yourself, e.g. using a migration.

Managing settings' values

If you added the route described above you can manage the values of all defined settings in a simple form. By default, you can access that form by browsing to app_dev.php/settings/modify. But you probably want to limit access to this form in your security configuration.

Reading settings

The bundle provides a service called effiana_config. Inside of a controller you can call

to retrieve the value of the setting name-of-a-setting. Furthermore, you can call

to get an associative array of all defined settings and their values.

will fetch only settings with the specified section (or those without a section if explicitly passing null for the name).

Writing settings

With the same service you can set new values of settings:

Keep in mind that the setting has to be present, or an exception will be thrown.

Usage in Twig templates

The Twig extension in this bundle supports reading settings directly in your template.

Enable caching (optional)

To reduce the number of database queries, you can set up a cache for settings. First, you have to choose which cache implementation you'd like to use. Currently, there are adapters available for:

Refer to the documentation of each implementation for details and read on in the corresponding section below. When done, ConfigBundle will automatically cache settings (using the built-in effiana_config_cache_adapter service).

Keep in mind to clear the cache (if needed) after modifying settings outside of your app (e.g. by Doctrine migrations):

Cache implementation: DoctrineCacheBundle

Set the parameter effiana_config.cache_adapter.class appropriately and configure a so-called cache provider with the alias effiana_config_cache_provider:

Cache implementation: Symfony Cache component

Set the parameter effiana_config.cache_adapter.class appropriately and configure a so-called cache pool with the service id effiana_config_cache_provider:

Customization

Redirect to a different page after submitting the built-in form

If you've enabled the build-in form, you can define where to redirect on successfully saving the changes by setting the target route name:

Rendering of settings in sections

If you want to render settings in a group (called section here), you'll have to assign those settings a common section name (in the database). Optionally, you can influence the order of these sections:

Settings without a section will be rendered at first. Sections without explicit ordering are rendered at last.

Translation

You can add translations for all settings (and sections) to be shown in the form by adding them to translation files with the ConfigBundle domain, e.g.

Using a custom entity for settings

The custom entity has to provide a mapping for the field value. The class BaseSetting defines this field, but no mapping for it. This allows easy overriding, including the data type. In the following example, the value field will be mapped to a text column, which will in turn render the built-in form fields as textarea.

So create the entity and its appropriate mapping:

And make the bundle aware of it:


All versions of config-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
doctrine/doctrine-bundle Version ^1.11 | ^2.0
symfony/framework-bundle Version ~4.3 | ^5.0
effiana/migration-bundle Version dev-master
craue/formflow-bundle Version ^3.2
twig/twig Version ^3.0
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 effiana/config-bundle contains the following files

Loading the files please wait ....