PHPackages                             fiedsch/contao-components - 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. fiedsch/contao-components

Abandoned → [fiedsch/contao-jsonwidget](/?search=fiedsch%2Fcontao-jsonwidget)Contao-module[Utility &amp; Helpers](/categories/utility)

fiedsch/contao-components
=========================

additional components for Contao Open Source CMS

v0.6.4(8y ago)0141MITPHPPHP &gt;=5.6CI failing

Since Nov 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/fiedsch/contao-components)[ Packagist](https://packagist.org/packages/fiedsch/contao-components)[ RSS](/packages/fiedsch-contao-components/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (4)Versions (8)Used By (1)

Components for Contao
=====================

[](#components-for-contao)

Abandoned! Please use `fiedsch/contao-jsonwidget` instead.

Widgets
-------

[](#widgets)

### JSON widget

[](#json-widget)

The `jsonWidget` can be used in DCA files to create a text field that contains a JSON string. While saving it will be checked if that the string is valid JSON. The widget displays the JSON string with `JSON_PRETTY_PRINT` so that checks by the reader are are easier.

#### Example: extending Members

[](#example-extending-members)

```
$GLOBALS['TL_DCA']['tl_member']['fields']['json_data'] = [
   'inputType' => 'jsonWidget',
   'label'     => &$GLOBALS['TL_LANG']['tl_member']['json_data'],
   'eval'      => ['tl_style'=>'long', 'decodeEntities'=>true, 'allowHtml'=>true ],
   'sql'       => "blob NULL",
 ];

 // Add json_data to $GLOBALS['TL_DCA']['tl_member']['palettes']['default']
 // where ever you like
```

Other valid options in `eval` are the same as for `textarea`s (as `WidgetJSON` extends `TextArea`), except that setting `rte` will be ignored because the editors provided do not make sense here.

#### How to use that?

[](#how-to-use-that)

Extend `tl_member` as in the above example. Then create an `ExtendedMemberModel` that extends Contao's `MemberModel`. In the magic methodd `__set()` and `_get` you can intercept the "fields" stored in `json_data`. The `Fiedsch\JsonGetterSetterTrait` takes care of that:

```
// models/ExtendedMemberModel.php
namespace Contao;

class ExtendedMemberModel extends \MemberModel
{
    // let __set() and __get take care of the JSON data
    use \Fiedsch\JsonGetterSetterTrait;

  /**
    * The column name we selected for the `jsonWidget` in the example above
    * @var string
    */
    protected static $strJsonColumn = 'json_data';

}
```

```
// config/config.php
$GLOBALS['TL_MODELS']['tl_member'] = 'Contao\ExtendedMemberModel';
```

```
// config/autoload.php
// ...
ClassLoader::addClasses(
    [
        // ...
        'Contao\ExtendedMemberModel' => 'system/modules/your_extension/models/ExtendedMemberModel.php',
        // ...
    ]
);
// ...
```

#### And finally ...

[](#and-finally-)

```
$member = \ExtendedMemberModel::findById(42);

// access fields columns created by contao's default DCA
printf("read member %s %s\n", $member->firstname, $member->lastname);

// access a field stored in our JSON data column
printf("transparently accessing a field from the JSON data ... '%s'\n", $member->whatever);

// set values and store in database
$member->a_key_for_a_scalar_value = "fourtytwo";
$member->key_for_an_array = ['an','array','containing','some','strings'];
$member->save();
```

Helper Classes
--------------

[](#helper-classes)

### Reading YAML config files (mostly experimental)

[](#reading-yaml-config-files-mostly-experimental)

```
use Fiedsch\YamlConfigHelper;

$defaults = [
   'messages' => [
                   'de' => 'Guten Tag',
                   'fr' => 'Bonjour',
                   'en' => 'Hello',
                  ]
           ];
$config = new YamlConfigHelper('files/config/config.yaml', $defaults);
```

If `files/config/config.yml` does not exist it will be created with the data specified in (the optional parameter) `$defaults`:

```
messages:
    de: 'Guten Tag'
    fr: 'Bonjour'
    en: 'Hello'
```

Use the `YamlConfigHelper` instance `$config` like so:

```
$config->getEntry('data.messages.de'); // 'Guten Tag'
$config->getEntry('data.messages.es'); // null
```

Let's say that as expected `files/config/config.yaml` exists and contains

```
   messages:
       de: 'Guten Morgen'
       fr: 'Bonjour'
       en: 'Good Morning'
```

You would get

```
$config->getEntry('data.messages.de'); // 'Guten Morgen'
$config->getEntry('data.messages.es'); // null
```

with the data in `$defaults` being ignored. There will be no merge of what is read from the config file and the specified `$defaults`!

For details using Symfony's `ExpressionLanguage` see [http://symfony.com/doc/current/components/expression\_language.html](http://symfony.com/doc/current/components/expression_language.html)

#### Specifying a default

[](#specifying-a-default)

With the config data as above:

```
$config->getEntry('data.messages.es'); // null
$config->getEntry('data.messages.es', "¡buenos días!"); // "¡buenos días!"
```

#### Data types

[](#data-types)

with the configuration file as above

```
$config->getEntry('data.messages');
/*
object(stdClass)#233 (3) {
  ["de"]=>
  string(12) "Guten Morgen"
  ["fr"]=>
  string(7) "Bonjour"
  ["en"]=>
  string(12) "Good Morning"
}
*/
```

returns a `stdClass` Instance. If you need the data as an `array`, you have to type cast to `array`

```
(array)$config->getEntry('data.messages');
/*
array(3) {
  ["de"]=>
  string(12) "Guten Morgen"
  ["fr"]=>
  string(7) "Bonjour"
  ["en"]=>
  string(12) "Good Morning"
}
*/
```

### Please note

[](#please-note)

Using

```
$config = new YamlConfigHelper('files/sompe/path/to/a/file.yaml');
```

please note that `file.yaml` is publicly accessible (in Contao 3) unless some folder along the path `files/sompe/path/to/a/` is protected by a `.htaccess file` (the lock icon in the Contao backend).

If you want to make the file editable for Contao backend users:

- place it in (a folder below) `files/`
- make the file extension `.yaml` so Contaos syntax highlighting will be triggered (which will not happen with a `.yml` extension)
- add `yaml` to Contaos list of "editable file types" (found in System, Settings)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~69 days

Recently: every ~75 days

Total

7

Last Release

3097d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5047601?v=4)[Andreas Fieger](/maintainers/fiedsch)[@fiedsch](https://github.com/fiedsch)

---

Top Contributors

[![fiedsch](https://avatars.githubusercontent.com/u/5047601?v=4)](https://github.com/fiedsch "fiedsch (21 commits)")

---

Tags

componentscontaocomponentscontaowidgets

### Embed Badge

![Health badge](/badges/fiedsch-contao-components/health.svg)

```
[![Health](https://phpackages.com/badges/fiedsch-contao-components/health.svg)](https://phpackages.com/packages/fiedsch-contao-components)
```

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49517.1k](/packages/blackfire-player)[terminal42/contao-url-rewrite

URL Rewrite bundle for Contao Open Source CMS

15100.0k3](/packages/terminal42-contao-url-rewrite)[terminal42/contao-leads

Leads extension for Contao Open Source CMS; Store and manage form data with ease!

35174.3k10](/packages/terminal42-contao-leads)[contao-community-alliance/dc-general

Universal data container for Contao

1579.5k90](/packages/contao-community-alliance-dc-general)[contao-bootstrap/core

Core of Contao Bootstrap extension

1590.7k17](/packages/contao-bootstrap-core)

PHPackages © 2026

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