Download the PHP package mukadi/settings-bundle without Composer
On this page you can find all versions of the php package mukadi/settings-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mukadi/settings-bundle
More information about mukadi/settings-bundle
Files in mukadi/settings-bundle
Package settings-bundle
Short Description this bundle provide a global app settings form fully customisable
License MIT
Informations about the package settings-bundle
MukadiSettingsBundle
this bundle provide a global app settings form fully customisable.
You can render the settings form in admin page for example. The form building is centralized under the bundle configuration.
Features:
- Settings can be stored via Doctrine ORM.
- Form building centralized in config files (e.g: config.xml or an imported settings.yml file)
- A Service for querying stored settings.
Installation
if you want to use symfony flex run the following command in your project:
Install the bundle via composer by running the command:
If you're not using Symfony Flex, you must follow next instructions to configure the bundle yourself.
Configuration
Enable the bundle in the kernel:
Create the Param class
First, create your Param class by extending the base Param
class (the class to use depends of your storage)
Add packages configuration file
Configure the bundle for using this class, and optionnaly specifying the current Object Manager used by the application, if 'manager' key is missing the default Doctrine entity manager will be used:
Now that the bundle is configured, the last thing you need to do is update your database schema because you have added a new entity. For ORM run the following command.
Build the form
Below is a minimal example of the necessary configuration for build a settings form:
The currently supported types are:
- text : simple text field, save setting as plain text in the database
- integer : input for integer
- toggle : a simple checkbox
- number: input for number (decimals and float)
- textarea: multi-lines text input
- entity: for select an entity in the database. The bundle store only the
id
. - email: input for email adresses
- datetime: input for date and time
- date: input for date
Usage
Now that you have properly create your settings form. You can render it a custom SonataAdminBundle
action page, or in any view in your application:
In the controller use the mukadi_settings.setting
service for getting the form (Or use the Mukadi\SettingsBundle\Model\Setting
class if you're using the autowiring)
And in your view, render the form like any other form:
When the form is submitted, in your controller you must handle that request if you want to store the updated settings in your database.
And finally you can retrieve the stored data via the mukadi_settings.setting
service like this:
All versions of settings-bundle with dependencies
symfony/framework-bundle Version ^3.4||^4.0
doctrine/doctrine-bundle Version ^1.0
doctrine/orm Version ^2.2
symfony/form Version ~3.4|~4.0