contao-community-alliance/composer-plugin
Composer plugin for Contao 3 extensions: installs packages from vendor into system/modules via copy/symlink so Contao can detect them. Helps keep legacy Contao 3 module structure working in Composer setups (also usable when supporting Contao 4 legacy mode).
system/modules/) conflicts with Laravel’s PSR-4 autoloading and vendor-based dependency isolation. A Laravel project would need to:
system/modules/) alongside Laravel’s conventions, risking namespace pollution or autoload conflicts.TL_* classes).composer.json (not a Laravel package’s composer.json), limiting granularity.TL_Module hooks).| Risk Area | Impact | Mitigation Strategy |
|---|---|---|
| Namespace Collisions | Contao 3 modules use global namespace or non-PSR-4 autoloading. | Isolate Contao modules in a subdirectory (e.g., contao-modules/) and use custom autoload maps. |
| Filesystem Conflicts | system/modules/ symlinks may clash with Laravel’s storage/, public/, or vendor/. |
Use absolute paths in contao config and exclude Contao modules from Laravel’s autoloader. |
| Database Schema | Contao modules may extend Contao’s database tables (e.g., tl_content). |
Validate schema compatibility with Laravel’s migrations and use Contao’s runonce for updates. |
| Dependency Isolation | Contao 3 modules may require PHP extensions (e.g., gd, intl) not used by Laravel. |
Document server requirements and use Composer’s conflict rules to block incompatible packages. |
| Long-Term Maintenance | Contao 3 is end-of-life (EOL). The plugin may deprecate or break with Contao 4. | Plan for migration to Symfony bundles or Laravel-compatible Contao 4 modules. |
Why Contao 3?
Laravel Integration Strategy
composer.json autoload maps?)TL_Hooks or a Laravel service provider?)Deployment Workflow
system/modules/ symlinks be managed in CI/CD? (e.g., Docker volumes, post-deploy scripts?)runonce scripts conflict with Laravel’s migrations?Future-Proofing
vendor/contao-modules)?Laravel + Contao 3 Hybrid:
composer.json (not a Laravel package).vendor/, separate system/).TL_*) will pollute Laravel’s global namespace.index.php?do=module) will not integrate with Laravel’s router.Alternative Approaches:
| Approach | Pros | Cons |
|---|---|---|
| Use Plugin as-Is | Minimal changes; leverages Contao community support. | High risk of conflicts; no Laravel integration. |
| Custom Laravel Composer Plugin | Full control over autoloading/routing. | High development effort; no Contao community support. |
| Symfony Bundles (Contao 4) | Native Laravel/Symfony compatibility. | Requires rewriting Contao 3 modules; Contao 4 may not be viable. |
| Static File Copy (No Plugin) | Avoids Composer plugin overhead. | Manual symlink management; no runonce support. |
Assess Contao 3 Dependencies:
registerHook() or TL_Module directly).Configure Root composer.json:
{
"require": {
"contao/core-bundle": "~3.5",
"contao-community-alliance/composer-plugin": "~2.4 || ~3.0"
},
"extra": {
"contao": {
"sources": {
"vendor/contao-modules/module1": "system/modules/module1"
}
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
// Exclude Contao modules from Laravel's autoloader
},
"files": [
"vendor/contao-modules/module1/config/autoload.php"
]
}
}
files autoload for Contao modules that need legacy class loading.Isolate Contao Filesystem:
system/ outside Laravel’s vendor/ (e.g., public/contao/system/).TL_ROOT to point to the shared directory.Handle Routing:
rewrite middleware to proxy Contao requests to index.php.// routes/web.php
Route::prefix('contao')->group(function () {
Route::get('{path}', function ($path) {
return app()->handle(
Request::create("/contao/index.php?do=$path")
);
});
});
Database Integration:
Schema::connection() to manage Contao tables.Schema::connection('contao')->table('tl_content')->get();
| Component | Compatibility Risk | Mitigation |
|---|---|---|
| Autoloading | High | Exclude Contao modules from PSR-4; use files autoload for TL_* classes. |
| Routing | High | Proxy Contao requests via Laravel routes. |
| Database | Medium | Use separate database connections. |
| Configuration | Medium | Merge Contao’s config/ with Laravel’s .env. |
| Asset Pipeline | Low | Serve Contao assets via Laravel’s mix or asset() helper. |
Phase 1: Proof of Concept
hello world module).Phase 2: Integration
Phase 3: CI/CD Pipeline
How can I help you explore Laravel packages today?