Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Manager Plugin Laravel Package

contao/manager-plugin

Provides Contao Manager integration hooks for Composer packages. Lets extensions register with the Contao Manager, add configuration and plugin logic for installs/updates, and streamline compatibility with the Contao CMS Manager workflow.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Add the package via Composer in your Laravel project (if applicable—note: this is a Contao Manager plugin, not a Laravel-specific package, but can be adapted for Laravel-based Contao integrations):

    composer require contao/manager-plugin
    

    Note: This package is primarily for Contao CMS, but if you're using Laravel with Contao via a bridge (e.g., laravel-contao), ensure compatibility.

  2. Register the Plugin In your Contao installation, add the plugin to config/config.php under managerPlugins:

    $GLOBALS['TL_MANAGER_PLUGINS'][] = 'vendor\\manager\\plugin\\ClassName';
    
  3. First Use Case Create a basic plugin class extending Contao\ManagerPlugin\AbstractPlugin:

    namespace Vendor\ManagerPlugin;
    
    use Contao\ManagerPlugin\AbstractPlugin;
    use Contao\ManagerPlugin\Configuration\Version;
    
    class MyPlugin extends AbstractPlugin
    {
        public function getConfiguration()
        {
            return new Version('1.0.0', '1.0.0', '1.0.0', '2023-01-01', 'Contao 4.9+');
        }
    }
    
    • Override getConfiguration() to define metadata (version, compatibility).
    • Implement hooks (e.g., onLoad, onInstall) for lifecycle events.

Implementation Patterns

Core Workflows

  1. Plugin Lifecycle Hooks Leverage hooks to integrate with Contao Manager’s workflow:

    public function onInstall()
    {
        // Run migrations, setup tasks, or post-install logic.
    }
    
    public function onUninstall()
    {
        // Cleanup logic (e.g., delete database entries).
    }
    
  2. Dependency Management Declare dependencies in getConfiguration():

    public function getConfiguration()
    {
        return new Version(
            '1.0.0',
            '1.0.0',
            '1.0.0',
            '2023-01-01',
            'Contao 4.9+',
            ['contao/core-bundle' => '4.9.*'] // Example dependency
        );
    }
    
  3. UI Integration (Optional) Extend the Manager UI by implementing getMenuItems() or getSubscribedServices() for custom admin panels or services.

  4. Laravel Adaptation (If Applicable) If using Laravel with Contao, wrap the plugin in a Laravel service provider to bridge events:

    // app/Providers/ContaoManagerPluginServiceProvider.php
    public function boot()
    {
        if (class_exists('Contao\ManagerPlugin\Manager')) {
            $manager = new \Contao\ManagerPlugin\Manager();
            $manager->registerPlugin(new \Vendor\ManagerPlugin\MyPlugin());
        }
    }
    

Gotchas and Tips

Pitfalls

  1. Namespace Conflicts Ensure plugin classes use unique namespaces (e.g., Vendor\ManagerPlugin\*) to avoid collisions with Contao core or other plugins.

  2. Version Mismatches

    • Contao Manager enforces strict version compatibility. Test plugins across Contao versions (e.g., 4.9, 4.10) to avoid TL_Exception during installation.
    • Use composer.json constraints to align with Contao’s semver (e.g., ^4.9).
  3. Hook Timing

    • onLoad runs during plugin initialization but before dependencies are resolved. Use onInstall for dependency-heavy logic.
    • Avoid blocking operations in getConfiguration() (e.g., file I/O).
  4. Laravel-Specific Quirks

    • Contao Manager plugins do not auto-load in Laravel. Manually instantiate and register them in a service provider.
    • Database migrations may conflict with Contao’s schema. Use Laravel’s Schema::table() carefully.

Debugging Tips

  • Enable Debug Mode Set TL_DEBUG to true in config/localconfig.php to log Manager plugin errors:

    define('TL_DEBUG', true);
    
  • Check Manager Logs Errors appear in /system/logs/contao_manager.log (if logging is configured).

  • Validate Configuration Use php bin/contao-manager.php list to verify plugin registration:

    ./contao-manager.php list
    

Extension Points

  1. Custom Commands Extend Contao Manager’s CLI with getCommands():

    public function getCommands()
    {
        return [
            new \Vendor\ManagerPlugin\CustomCommand(),
        ];
    }
    
  2. Dynamic Plugin Loading Load plugins conditionally based on environment variables or Contao features:

    public function onLoad()
    {
        if (TL_MODE === 'BE' && \Input::get('key') === 'my_plugin') {
            // Enable plugin only in backend.
        }
    }
    
  3. Asset Bundling For frontend assets, use Contao’s asset pipeline or Laravel Mix, then reference them in getConfiguration():

    public function getAssets()
    {
        return [
            'css' => 'bundles/myplugin/style.css',
            'js'  => 'bundles/myplugin/script.js',
        ];
    }
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity