PHPackages                             contao-community-alliance/composer-plugin - 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. contao-community-alliance/composer-plugin

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

contao-community-alliance/composer-plugin
=========================================

Composer plugin that provides installers for contao-module and legacy-contao-module.

3.2.6(2w ago)7686.2k↓52.9%1120LGPL-3.0-or-laterPHPPHP ^7.1 || ^8.0

Since Mar 10Pushed 2d ago15 watchersCompare

[ Source](https://github.com/contao-community-alliance/composer-plugin)[ Packagist](https://packagist.org/packages/contao-community-alliance/composer-plugin)[ Docs](http://c-c-a.org/)[ RSS](/packages/contao-community-alliance-composer-plugin/feed)WikiDiscussions 3.2 Synced 2d ago

READMEChangelogDependencies (10)Versions (54)Used By (20)

Contao Composer Plugin
======================

[](#contao-composer-plugin)

[![Version](https://camo.githubusercontent.com/e7139be5583ffdb4e37067b89496f0383b38fc9d22dd0a2a44985ff2dd9b5943/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f6e74616f2d636f6d6d756e6974792d616c6c69616e63652f636f6d706f7365722d706c7567696e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/contao-community-alliance/composer-plugin)[![License](https://camo.githubusercontent.com/b48f9e245a40c2868819e24247b62ea6c70e31d1fbf37a2d43295094127e12db/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f6e74616f2d636f6d6d756e6974792d616c6c69616e63652f636f6d706f7365722d706c7567696e2e7376673f7374796c653d666c61742d737175617265)](http://spdx.org/licenses/LGPL-3.0+)[![Downloads](https://camo.githubusercontent.com/acb7176095a789a58ae5cd25c9bca480f3b02c3b48c78248712b711274d70150/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6e74616f2d636f6d6d756e6974792d616c6c69616e63652f636f6d706f7365722d706c7567696e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/contao-community-alliance/composer-plugin)

The Contao Composer plugin is responsible for correctly installing Contao 3 extensions in a Composer environment. Composer files are always located in the `vendor` folder, but they must be copied/symlinked to `system/modules`to be correctly detected by Contao.

Be aware that this plugin is not necessary for Contao 4 / Symfony bundles. If you however do support both Contao 3 and Contao 4, make sure to follow the *old* way which is still fully supported in Contao 4. You will obviously not be able to use new bundle features (like the DIC) though.

composer.json
-------------

[](#composerjson)

Follow the [Composer manual](https://getcomposer.org/doc/02-libraries.md) on how the basic `composer.json` in your library should look like.

A few simple rules will make your package compatible with Contao 3:

1. Change the type of your package to `contao-module`
2. Add a requirement for the correct Contao version
3. Add a requirement to the Contao Composer plugin
4. Add the sources to the `extras => contao` section
5. If necessary, specify your runonce files

**Example:**

```
{
    "name": "vendor/package-name",
    "type": "contao-module",
    "license": "LGPL-3.0+",
    "require": {
        "contao/core-bundle": "4.*",
        "contao-community-alliance/composer-plugin": "3.*"
    },
    "extra": {
        "contao": {
            "sources": {
                "": "system/modules/extension-name"
            },
            "runonce": [
                "config/update.php"
            ]
        }
    },
    "replace": {
        "contao-legacy/extension-name": "self.version"
    }
}
```

### Require Contao

[](#require-contao)

In Contao 4, the bundled modules were restructured so each module is a separate Symfony bundle. This means that a user can decide not to install the news or calendar extension if it's not needed for their system.

Your extension should always `require contao/core-bundle` in the appropriate version (see *About semantic versioning*). If your code is extending other modules like news or calendar, make sure to add correct requirements for the respective Symfony bundles (e.g. `contao/news-bundle` or `contao/calendar-bundle`).

Contao 4 was designed to be backwards-compatible with Contao 3. Therefore, it is very much possible to have an extension that does support both Contao 3 and Contao 4. If your extension works with Contao 3.5 and Contao 4, a correct requirement could look like this:

```
{
    "require": {
        "contao/core-bundle": "~3.5 || ~4.1"
    }
}
```

### Require the Contao Composer Plugin

[](#require-the-contao-composer-plugin)

There are two different versions of the Plugin currently actively supported.

- Version 2 of the plugin is made for Contao 3. It supports installing Composer packages in `TL_ROOT/composer`instead of the root directory of your installation.
- Version 3 of the plugin is made for Contao 4. In Contao 4, the `vendor` folder is located in your installation root, and Contao is just another dependency of your installation.

Make sure to require the correct version of the plugin. If your module does support Contao 3 and Contao 4, the correct require statement looks like this:

```
{
    "require": {
        "contao-community-alliance/composer-plugin": "~2.4 || ~3.0"
    }
}
```

Versions older than 2.4 will not support `contao/core-bundle`, so make sure to set a correct dependency. If you only support Contao 4, the required version would simply be `3.*`. However, you should probably create a Symfony bundle and not require the Contao Composer Plugin at all…

Be aware that your root project (the `composer.json` in your root folder) should be of type *project*, otherwise the plugin will not install Contao sources.

### Sources

[](#sources)

In the sources section, you can define which files should be copied where on installation. This is necessary for Contao 3 extensions to be installed in the `system/modules` folder.

If your GIT repository contains only files that should be copied into the `system/modules/extension-name` folder, simply specify an empty source and the target folder.

```
{
    "extra": {
        "contao": {
            "sources": {
                "": "system/modules/extension-name"
            }
        }
    }
}
```

However, you could also restructure your GIT so that Contao files live in their own folder. In this case, you can use the Composer autoloader and follow [PSR-0](http://www.php-fig.org/psr/psr-0/) or [PSR-4](http://www.php-fig.org/psr/psr-4/) namespaces. However, your extension is then incompatible with the old extension repository.

You can define multiple files or folder to be copied/symlinked into the Contao installation. Your package can even install multiple Contao extensions at once.

```
{
    "extra": {
        "contao": {
            "sources": {
                "config": "system/modules/extension-name/config",
                "dca": "system/modules/extension-name/dca",
                "templates": "system/modules/extension-name/templates"
            }
        }
    },
    "autoload": {
        "psr-4": {
            "VendorName\\ExtensionName\\": "src/"
        }
    }
}
```

### Userfiles

[](#userfiles)

The `userfiles` property allows to copy files from a Composer package to the `/files` folder in Contao. As this folder can be renamed in the Contao configuration, the installer automatically tries to find the correct location.

Be aware that userfiles are only copied once if they do not exist, they are not overwritten on an update.

```
{
	"extra": {
		"contao": {
			"userfiles": {
				"src/system/modules/my-module/files/images": "my-module/images"
			}
		}
	}
}
```

### Runonces

[](#runonces)

Putting `runonce.php` files into your extension's `config` directory is a bad practice with Composer. The file will be deleted by Contao after it's executed, which means Composer will complain about modified files on the next update. To work around this, you can specify a list of runonce files in the `composer.json`. They will be executed after each installation or update, but they won't be deleted. There is no need to name them `runonce.php` either, feel free to use any other name.

```
{
    "extra": {
        "contao": {
            "runonce": [
                "src/system/modules/extension-name/runonce/init_update.php",
                "src/system/modules/extension-name/runonce/do_db_update.php",
                "src/system/modules/extension-name/runonce/refresh_entities.php"
            ]
        }
    }
}
```

The runonce files will be executed in the order you specify them.

About semantic versioning
-------------------------

[](#about-semantic-versioning)

Following [Semanting Versioning](http://semver.org) is crucial to the success of Composer installation. If you (the developer) do not follow semantic versioning, it is very hard for others, (and the dependency manager) to install correct versions of your library.

You should also get familiar with the [Composer version constraints](https://getcomposer.org/doc/articles/versions.md) to correctly set your dependencies. Incorrect dependencies will lead to broken installations, and it's **always** the developer's fault!

Server requirements
-------------------

[](#server-requirements)

The Contao Composer Plugin requires an up-to-date server configuration. Contao 4 does no longer support the so-called "safe mode hack", and the plugin now requires symlink support.

###  Health Score

70

—

ExcellentBetter than 100% of packages

Maintenance99

Actively maintained with recent releases

Popularity44

Moderate usage in the ecosystem

Community51

Growing community involvement

Maturity82

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~84 days

Recently: every ~246 days

Total

54

Last Release

14d ago

Major Versions

2.4.0 → 3.0.02016-02-05

2.4.2 → 3.0.22016-05-24

2.4.3 → 3.0.32016-08-11

2.4.x-dev → 3.0.52017-04-25

PHP version history (6 changes)2.2.3PHP &gt;=5.3.2

3.0.0PHP &gt;=5.4.0

3.0.7PHP ^5.4 || ^7.0

3.1.0PHP ^5.6 || ^7.0

3.1.4PHP ^5.6 || ^7.0 || ^8.0

3.2.0PHP ^7.1 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44649522?v=4)[xtra](/maintainers/xtra)[@xtra](https://github.com/xtra)

![](https://avatars.githubusercontent.com/u/10211934?v=4)[Chibineko](/maintainers/Chibineko)[@chibineko](https://github.com/chibineko)

![](https://avatars.githubusercontent.com/u/8189209?v=4)[netzmacht](/maintainers/netzmacht)[@netzmacht](https://github.com/netzmacht)

![](https://avatars.githubusercontent.com/u/8672569?v=4)[California College of Arts](/maintainers/cca)[@cca](https://github.com/cca)

---

Top Contributors

[![discordier](https://avatars.githubusercontent.com/u/940331?v=4)](https://github.com/discordier "discordier (212 commits)")[![tristanlins](https://avatars.githubusercontent.com/u/343404?v=4)](https://github.com/tristanlins "tristanlins (184 commits)")[![aschempp](https://avatars.githubusercontent.com/u/1073273?v=4)](https://github.com/aschempp "aschempp (83 commits)")[![backbone87](https://avatars.githubusercontent.com/u/1196313?v=4)](https://github.com/backbone87 "backbone87 (11 commits)")[![dominikzogg](https://avatars.githubusercontent.com/u/1011217?v=4)](https://github.com/dominikzogg "dominikzogg (9 commits)")[![baumannsven](https://avatars.githubusercontent.com/u/2493263?v=4)](https://github.com/baumannsven "baumannsven (6 commits)")[![qzminski](https://avatars.githubusercontent.com/u/193483?v=4)](https://github.com/qzminski "qzminski (5 commits)")[![Zeromax](https://avatars.githubusercontent.com/u/1867177?v=4)](https://github.com/Zeromax "Zeromax (4 commits)")[![minstyle](https://avatars.githubusercontent.com/u/2649562?v=4)](https://github.com/minstyle "minstyle (3 commits)")[![dmolineus](https://avatars.githubusercontent.com/u/1186266?v=4)](https://github.com/dmolineus "dmolineus (3 commits)")[![fritzmg](https://avatars.githubusercontent.com/u/4970961?v=4)](https://github.com/fritzmg "fritzmg (2 commits)")[![m-vo](https://avatars.githubusercontent.com/u/5305677?v=4)](https://github.com/m-vo "m-vo (1 commits)")[![bytehead](https://avatars.githubusercontent.com/u/754921?v=4)](https://github.com/bytehead "bytehead (1 commits)")[![Toflar](https://avatars.githubusercontent.com/u/481937?v=4)](https://github.com/Toflar "Toflar (1 commits)")[![ausi](https://avatars.githubusercontent.com/u/367169?v=4)](https://github.com/ausi "ausi (1 commits)")

### Embed Badge

![Health badge](/badges/contao-community-alliance-composer-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/contao-community-alliance-composer-plugin/health.svg)](https://phpackages.com/packages/contao-community-alliance-composer-plugin)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.2k](/packages/friendsofphp-php-cs-fixer)[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k16.7M1.0k](/packages/phpro-grumphp)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)

PHPackages © 2026

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