This package is abandoned and no longer maintained. The author suggests using the netzmacht/contao-toolkit package instead.

This library provides tools to simplify common tasks when developing with Contao.

dev-master / 1.0.x-dev 2015-01-12 14:11 UTC

This package is auto-updated.

Last update: 2022-02-01 12:42:59 UTC


Build Status Version License Downloads Contao Community Alliance coding standard

This library provides tools for solving common tasks required when developing for Contao CMS.


You can install this library using Composer.

$ php composer.phar require netzmacht/contao-dev-tools:~1.0


DCA related features

####Toggle icon callback

This library ships with a common toggle state icon callback.


// dca/tl_custom.php

$GLOBALS['TL_DCA']['tl_custom']['fields']['published']['button_callback'] = 
		'tl_custom',	// The database table.
		'published',	// the state column
		false,			// Inverse the state. Set to true for invisible='' columns
		'invisible.gif' // Disabled icon. If not set, icons are transformed from edit.gif to edit_.gif

####Convert models to options

One standard task using Contao models is to transform when to options for select lists or checkbox menus. Dev-Tools simplifies it for you.

  • Convert collections to options arrays.
  • Use callbacks to customize the labels.
  • Group values by a third column/callback value.

public function yourOptionsCallback()
	$collection = \PageModel::findAll();
	// Empty collections by Contao are NULL. The OptionsBuilder handles is correctly.
	return Netzmacht\Contao\DevTools\Dca\Options\OptionsBuilder::fromCollection($collection, 'id', 'name')

###Dependency injection

Contao does not provide any help for dependency injection. If you need some dependencies from the 
[dependency container]( you can use this Trait:


class YourContentElement extends \ContentElement
	use Netzmacht\Contao\DevTools\ServiceContainerTrait;
	private $service;
	public function __construct($model)
		$this->service = $this->getService('your-required-service');


  • PHP 5.4 is required.
  • Contao 3.2 - 3.4 is supported.
  • contao-community-alliance/dependency-container ~1.6 is required.