Download the PHP package dwalczyk/setting-bundle without Composer
On this page you can find all versions of the php package dwalczyk/setting-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dwalczyk/setting-bundle
More information about dwalczyk/setting-bundle
Files in dwalczyk/setting-bundle
Package setting-bundle
Short Description Symfony bundle that allows you to easily define, read and change settings.
License MIT
Homepage https://dawidwalczyk.pl
Informations about the package setting-bundle
Setting bundle
Setting bundle is a bundle of the Symfony framework that allows you to easily define, read and change settings.
Integrated with:
- symfony cache
- doctrine orm
- symfony profiler
- symfony serializer
- twig
Table of Contents
- Installation & configuration
- Usage
- Data storages
- Data transformers
- Doctrine data transformer
- Cache
- More effective user (setting owner) passing
- Twig
- Symfony profiler
Installation & configuration
-
Run composer require
-
create file
config/dwalczyk_setting.yaml
and paste the contents from below: -
Add to
config/doctrine.yaml
- Create and execute migration
Usage
- First we need to define the setting.
via php
or via yaml configuration
- Now you can read or set value globally or per user.
Data storages
Data storages are classes responsible for writing and reading previously saved settings.
Available built-in data storages:
-
- Doctrine ORM storage
You can create your custom data storage, just create symfony service that implements
DWalczyk\SettingBundle\DataStorageInterface
and insert its name to configuration.
Data transformers
Data transformers determine how to format data before writing and after reading from data storage.
They are also responsible for formatting the values from the "defaultValue" definition.
Built-in data transformers:
DoctrineDataTransformer
- handle doctrine types, read moreSerializerDataTransformer
- handle all types supported by symfony serializerNativePhpSerializerDataTransformer
- handle all types supported by serialize/unserialize native php functions
By default, data transformers are loaded in the order:
DoctrineDataTransformer
SerializerDataTransformer
If you want to use NativePhpSerializerDataTransformer
instead of SerializerDataTransformer
add this code to your config:
Or create custom data transformer
DoctrineDataTransformer
Supported types:
doctrine-entity<fqcn/of/entity>
- single entity e.g.doctrine-entity<App\Mail\Entity\MailTemplate>
doctrine-entity<fqcn/of/entity>[]
- multiple entity e.g.doctrine-entity<App\Mail\Entity\MailTemplate>[]
Cache
To use cache, you must configure cache in your symfony configuration and then cache
option in the bundle configuration.
or with custom pool:
if you don't want to use cache, leave the cache
option empty or do not define it.
More effective user (setting owner) passing
Implement SettingOwnerInterface
in your security user class.
Now you are able to call:
Twig
Functions:
Symfony profiler
All versions of setting-bundle with dependencies
doctrine/orm Version ^2.11
symfony/framework-bundle Version ^6.0|^7.0
webmozart/assert Version ^1.11
symfony/serializer Version ^6.0|^7.0
symfony/cache Version ^6.0|^7.0
symfony/stopwatch Version ^6.0|^7.0
twig/twig Version ^3.0
symfony/property-access Version ^6.0|^7.0