I used bin/console plugin:create
to create a theme plugin named IngoSDev6CertPrep
. I don’t remember how excactly I typed the name, but the wizard tried to write an escaped kebab-case version into the composer.json
that JsonLint warns is invalid:
[Seld\JsonLint\ParsingException]
"/var/www/html/custom/plugins/IngoSDev6CertPrep/composer.json" does not contain valid JSON
Parse error on line 2:
{ "name": "ingo-s\-dev6-cert-p
------------^
Invalid string, it appears you have an unescaped backslash at: \-dev
This affects the parts between vendor prefix and plugin name, maybe due to an unexpected capitalization. My vendor prefix ends with a capital „S“ which seemed to be valid so far. The plugin name starts with another capital letter, „D“, as I previously wrote everything together like „IngoSDev6CertPrep“. The theme wizard generates
- „name“: „ingo-s-dev6-cert-prep/ingo-s-dev6-cert-prep“,
- „shopware-plugin-class“: „IngoS\Dev6CertPrep\IngoSDev6CertPrep“,
- „autoload“: { „psr-4“: { „IngoS\Dev6CertPrep\“: „src/“
Update: I add a screenshot, as the forum seems to hide backslashes even if they are inside code blocks:
To make things worse, other theme
commands don’t complain, they seem to fail silently and my theme is just not visible in the theme list. It only occured to me to look into my theme plugin’s composer.json
when I tried to add the Symfony profiler which is missing in the current latest dockware/dev
container (Shopware 6.5.7.3) so I typed (at Shopware root):
composer require --dev symfony/profiler-pack
That also linted the subdirectories and stopped at my plugin error.
Expected behavior:
plugin:create
never creates invalid JSON:- there should be no unnecessary escaping:
\-
could be-
- optional escaping should always be correct:
\-
should be\\-
- dashes/hyphens should be ecaped correctly:
\\
between namespace parts
- there should be no unnecessary escaping:
- the theme name should not repeat both prefix and name:
"ingo-s-dev6-cert-prep/ingo-s-dev6-cert-prep"
should be"ingo-s/ingo-s-dev6-cert-prep"
theme
commands should lint and warn- top-level composer commands can’t be broken by invalid plugin code.
Recommendations:
If anyone else wants to create plugins or themes using the wizard, always check and edit the generated files before proceeding! Keeep theme/plugin names short and simple, and if you haven’t chosen a vendor prefix yet, don’t use optional uppercase after the first character!