PHPackages                             heimrichhannot/contao-utils-bundle - 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. heimrichhannot/contao-utils-bundle

ActiveContao-bundle[Utility &amp; Helpers](/categories/utility)

heimrichhannot/contao-utils-bundle
==================================

This bundle offers various utility functionality for the Contao CMS.

3.11.0(4mo ago)9120.4k↓19.1%4[1 issues](https://github.com/heimrichhannot/contao-utils-bundle/issues)20LGPL-3.0-or-laterPHPPHP ^8.1CI failing

Since Feb 27Pushed 4mo ago4 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-utils-bundle)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-utils-bundle)[ RSS](/packages/heimrichhannot-contao-utils-bundle/feed)WikiDiscussions v3 Synced 2w ago

READMEChangelog (10)Dependencies (63)Versions (581)Used By (20)

Contao Utils Bundle
===================

[](#contao-utils-bundle)

[![](https://camo.githubusercontent.com/3ce17e1d1e0bf2c958c19462fe24ec934e59bce0978a589c27480fc89132a60e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865696d7269636868616e6e6f742f636f6e74616f2d7574696c732d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-utils-bundle)[![](https://camo.githubusercontent.com/bd2bfc5afda50f121cf23d74b9458c7f6940116b0f22f50f86f8fd2f186938c2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865696d7269636868616e6e6f742f636f6e74616f2d7574696c732d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-utils-bundle)[![example branch parameter](https://github.com/heimrichhannot/contao-utils-bundle/actions/workflows/ci.yml/badge.svg?branch=v3)](https://github.com/heimrichhannot/contao-utils-bundle/actions/workflows/ci.yml/badge.svg?branch=v3)[![Coverage Status](https://camo.githubusercontent.com/7528ccb40af0134e9461a9c978fd158476ee7393e1dc61147fa6d5ece9200382/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6865696d7269636868616e6e6f742f636f6e74616f2d7574696c732d62756e646c652f62616467652e7376673f6272616e63683d7633)](https://coveralls.io/github/heimrichhannot/contao-utils-bundle?branch=v3)

> Hi, you're looking on a very new version of utils bundle, version 3! See [CHANGELOG.md](CHANGELOG.md) for more information! If you're looking for version 2, please check the [v2 branch](https://github.com/heimrichhannot/contao-utils-bundle/tree/v2).

Utils Bundle is a collection of many small helper to solve repeating task. At the center there is a utils service allow access to all util function. In addition, there are DcaField helpers, the Entity finder command and some nice twig filters.

Features
--------

[](#features)

- Utils-Service - A service allow access all bundled utils functions.
- DcaField registration - An nice api to add typical dca fields to your dca fields without repeating yourself or annoying order restrictions.
    - AuthorField - Add an author field with automatic filling of the default value and optional frontend member support
    - DateAddedField - Add a date added field to store the date of entity creation
- Entity Finder - A command to search for any contao entities in your database.
- Twig Filters

Install
-------

[](#install)

Just install it via composer or contao manager:

```
composer require heimrichhannot/contao-utils-bundle

```

Usage
-----

[](#usage)

### Utils service

[](#utils-service)

The Utils service is the core functionality of this bundle. It provides access to a lot of util functions help solving recurring tasks. It's build as one service from which you can access all utils services. The utils service is best used with dependency injection, but is also available from the service container as public service for usage in legacy code. You can check the [API Documentation](https://heimrichhannot.github.io/contao-utils-bundle/namespaces/heimrichhannot-utilsbundle-util.html) to see all available functions.

```
use HeimrichHannot\UtilsBundle\Util\Utils;

/**
 * A class containing examples usage of utils services. Please don't expect it to be useful :)
 */
class MyClass{
   /** @var Utils */
   protected $utils;

   public function __construct(Utils $utils) {
       $this->utils = $utils;
   }

   public function someActions(): bool {
        $dcaFields = $this->utils->dca()->getDcaFields('tl_content');
        $this->utils->array()->removeValue('headline', $dcaFields);
        foreach ($dcaFields as $dcaField) {
            echo $this->utils->string()->camelCaseToDashed($dcaField);
        }

        $rootPageModel = $this->utils->request()->getCurrentRootPageModel();
        echo $this->utils->anonymize()->anonymizeEmail($rootPageModel->adminEmail);

        $groupUsers = $this->utils->user()->findActiveUsersByGroup([1,2]);
        $this->utils->url()->addQueryStringParameterToUrl('user='.$groupUsers[0]->username, 'https://example.org');

        if ($this->utils->container()->isBackend()) {
            $where = $this->utils->database()->createWhereForSerializedBlob('dumbData', ['foo', 'bar']);
            $model = $this->utils->model()->findOneModelInstanceBy('tl_content', [$where->createAndWhere()], [$where->values]);
            echo '';
        }
}
```

### Static Utils

[](#static-utils)

Static helper methods that do not need to be injected are provided by the `SUtils` locator.

At this time, the following static helpers are available:

```
use HeimrichHannot\UtilsBundle\StaticUtil\SUtils;

SUtils::array()->insertBeforeKey($array, $keys, $newKey, $newValue);
SUtils::array()->insertAfterKey($array, $key, $value, $newKey = null, $options = []);
$foundAndRemoved = SUtils::array()->removeValue($value, $array);

SUtils::class()->hasTrait($class, $trait);
```

### Dca Fields

[](#dca-fields)

The bundle provides some common dca fields that can be used in your dca files.

#### Author field

[](#author-field)

Add an author field to your dca. It will be initialized with the current backend user. On copy, it will be set to the current user.

```
# contao/dca/tl_example.php
use HeimrichHannot\UtilsBundle\Dca\AuthorField;

AuthorField::register('tl_example');
```

You can pass additional options to adjust the field:

```
# contao/dca/tl_example.php
use HeimrichHannot\UtilsBundle\Dca\AuthorField;

AuthorField::register('tl_example')
    ->setType(AuthorField::TYPE_MEMBER) // can be one of TYPE_USER (default) or TYPE_MEMBER. Use TYPE_MEMBER to set a frontend member instead of a backend user
    ->setFieldNamePrefix('example') // custom prefix for the field name
    ->setUseDefaultLabel(false) // set to false to disable the default label and set a custom label in your dca translations
    ->setExclude(false) // set the dca field exclude option
    ->setFilter(false) // set the dca field filter option
    ->setSearch(false) // set the dca field search option
    ->setSorting(false) // set the dca field sorting option
;
```

#### Date added field

[](#date-added-field)

Add a date added field to your dca. It will set a timestamp on create or copy.

```
# contao/dca/tl_example.php
use HeimrichHannot\UtilsBundle\Dca\DateAddedField;

DateAddedField::register('tl_example');
```

You can pass additional options to adjust the field:

```
# contao/dca/tl_example.php
use HeimrichHannot\UtilsBundle\Dca\DateAddedField;

DateAddedField::register('tl_example')
    ->setExclude(false) // set the dca field exclude option
    ->setFilter(false) // set the dca field filter option
    ->setSearch(false) // set the dca field search option
    ->setSorting(true) // set the dca field sorting option
;
```

#### Alias field

[](#alias-field)

Add an alias field to your dca. Set the alias if the alias field is empty on save and check for duplicates.

```
use HeimrichHannot\UtilsBundle\Dca\AliasField;

AliasField::register('tl_example');
```

You can pass additional options to adjust the field:

```
# contao/dca/tl_example.php
use HeimrichHannot\UtilsBundle\Dca\AliasField;

AliasField::register('tl_example')
    AliasField::register('tl_md_newsletter')
    ->setAliasExistCallback([NewsletterCallbackListener::class, 'checkAliasExist']) // set a custom alias exist callback
    ->setExclude(false) // set the dca field exclude option
    ->setSearch(false) // set the dca field search option
    ->setFilter(false) // set the dca field filter option
    ->setSorting(true) // set the dca field sorting option
    ->setFlag(null) // set the dca field flag option
;
```

### Entity Finder

[](#entity-finder)

The entity finder is a command to search for any contao entities in your database.

**[Entity finder](docs/commands/entity_finder.md)**

### Twig Filters

[](#twig-filters)

This bundle contains currently one twig filter:

#### anonymize\_email

[](#anonymize_email)

Returns an anonymized email address.  will be max.\*\*\*\*@example.org

```
{{ user.email|anonymize_email }}
```

Notes
-----

[](#notes)

### Backwards Compatibility Promise

[](#backwards-compatibility-promise)

We try our best to keep this bundle backwards compatible and follow the principle of [semantic versioning](https://semver.org/).

Following aspects are not covered by BC promise:

- Using Utils classes direct instead from Utils service. This is not officially supported and may break your application due internal changes.
- Classes marked as `@internal` or `@experimental`

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance74

Regular maintenance activity

Popularity38

Limited adoption so far

Community36

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 79.8% 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 ~5 days

Recently: every ~11 days

Total

573

Last Release

131d ago

Major Versions

2.241.0 → 3.7.02025-03-19

2.243.0 → 3.9.02025-05-21

2.244.1 → 3.9.12025-07-18

2.244.2 → 3.9.32025-09-30

v2.x-dev → 3.10.22026-03-18

PHP version history (6 changes)1.0.0PHP &gt;=7.1.0

1.1.0PHP ^7.1

2.189.0PHP ^7.1|^8.0

2.196.0PHP ^7.2|^8.0

3.0.0-betaPHP ^8.1

2.239.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/28ad3224d8727b622ebd229840eea6b9dbcb83eb0bd609e6ce65b614830ff538?d=identicon)[digitales@heimrich-hannot.de](/maintainers/digitales@heimrich-hannot.de)

---

Top Contributors

[![koertho](https://avatars.githubusercontent.com/u/12064642?v=4)](https://github.com/koertho "koertho (426 commits)")[![ericges](https://avatars.githubusercontent.com/u/25957923?v=4)](https://github.com/ericges "ericges (88 commits)")[![mirkogleibe](https://avatars.githubusercontent.com/u/850300?v=4)](https://github.com/mirkogleibe "mirkogleibe (6 commits)")[![vvohh](https://avatars.githubusercontent.com/u/75325799?v=4)](https://github.com/vvohh "vvohh (5 commits)")[![AlexejKossmann](https://avatars.githubusercontent.com/u/32612134?v=4)](https://github.com/AlexejKossmann "AlexejKossmann (4 commits)")[![heimrich-hannot](https://avatars.githubusercontent.com/u/37208441?v=4)](https://github.com/heimrich-hannot "heimrich-hannot (1 commits)")[![fatcrobat](https://avatars.githubusercontent.com/u/480054?v=4)](https://github.com/fatcrobat "fatcrobat (1 commits)")[![MicioMax](https://avatars.githubusercontent.com/u/1090851?v=4)](https://github.com/MicioMax "MicioMax (1 commits)")[![Defcon0](https://avatars.githubusercontent.com/u/1485098?v=4)](https://github.com/Defcon0 "Defcon0 (1 commits)")[![qzminski](https://avatars.githubusercontent.com/u/193483?v=4)](https://github.com/qzminski "qzminski (1 commits)")

---

Tags

contaocontao5php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/heimrichhannot-contao-utils-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/heimrichhannot-contao-utils-bundle/health.svg)](https://phpackages.com/packages/heimrichhannot-contao-utils-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k18.3M430](/packages/easycorp-easyadmin-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M674](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M236](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1301.7M3.1k](/packages/contao-core-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k6.0M778](/packages/sylius-sylius)

PHPackages © 2026

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