User story
As a plugin developer adding lifecycle behavior to an existing Shopware plugin, I want the plugin entry class and lifecycle hooks generated correctly, so that the plugin remains valid and discoverable.
Problem
Shopware plugins do not use a conventional Bootstrap.php. The plugin entry class is normally src/<PluginName>.php. It must:
- extend
Shopware\Core\Framework\Plugin
- use the correct namespace
- match Composer PSR-4 autoloading
- be registered under
extra.shopware-plugin-class
- use the correct context types for lifecycle hooks
The generator must create a missing class or safely add missing lifecycle methods to an existing class without overwriting existing logic.
Example
shopware-cli extension create plugin-class \
--hooks install,activate,deactivate,update,uninstall
Possible updated files:
src/AcmePlugin.php
composer.json
Example generated class:
<?php declare(strict_types=1);
namespace Acme\Plugin;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
class AcmePlugin extends Plugin
{
public function activate(ActivateContext $activateContext): void
{
}
public function deactivate(DeactivateContext $deactivateContext): void
{
}
public function update(UpdateContext $updateContext): void
{
}
}
Out of scope
- implementing plugin-specific lifecycle behavior
- executing plugin installation or activation
- generating migrations or other plugin components
Why it matters
The value is keeping the plugin class, lifecycle signatures, file path, namespace, and Composer registration consistent when modifying an existing plugin.
Acceptance criteria
Readiness checklist
User story
As a plugin developer adding lifecycle behavior to an existing Shopware plugin, I want the plugin entry class and lifecycle hooks generated correctly, so that the plugin remains valid and discoverable.
Problem
Shopware plugins do not use a conventional
Bootstrap.php. The plugin entry class is normallysrc/<PluginName>.php. It must:Shopware\Core\Framework\Pluginextra.shopware-plugin-classThe generator must create a missing class or safely add missing lifecycle methods to an existing class without overwriting existing logic.
Example
Possible updated files:
Example generated class:
Out of scope
Why it matters
The value is keeping the plugin class, lifecycle signatures, file path, namespace, and Composer registration consistent when modifying an existing plugin.
Acceptance criteria
extension create plugin-classBootstrap.phpextra.shopware-plugin-classextra.shopware-plugin-classandcomposer.json autoload.psr-4; it does not hard-codesrc/<PluginName>.php.Shopware\Core\Framework\Plugininstall,postInstall,update,postUpdate,activate,deactivate, anduninstall. A generateduninstall()callsparent::uninstall()and returns without deleting data whenUninstallContext::keepUserData()is true.--hooksextra.shopware-plugin-classshopware-cli extension validateReadiness checklist