Skip to content

Automatic refactoring

Automatic refactoring

Shopware-CLI comes with a built-in automatic refactoring tool for PHP, JavaScript, and Admin Twig files.

It uses the tools:

  • Rector for PHP
  • ESLint for JavaScript
  • Custom rules for Admin Twig files

Refactoring an extension

WARNING

Make sure you have a copy of your extension before running the command, as it will change your files!

Refactoring an entire project

This will execute Rector and ESLint to refactor your code. You should review the changes made and decide whether you want to keep them or not.

Make sure that you have adjusted the shopware/core requirement in the composer.json file of your extension to the version you want to upgrade to. It will use the lowest supported version your Composer constraint is compatible with.

Experimental Twig upgrade using Large Language Models

The Extension Verifier also includes an experimental feature to upgrade your Twig templates using Large Language Models (LLMs). This feature is experimental and should only be executed on code that is versioned in Git or similar. To use this feature, you can run the following command:

Extension Verifier currently supports multiple providers:

  • gemini - Google Gemini LLM (requires GEMINI_API_KEY environment variable)
  • openrouter - OpenRouter API (requires OPENROUTER_API_KEY environment variable)
  • ollama - Local Ollama (uses localhost by default, OLLAMA_HOST environment variable can be used to specify a different host)

Our recommendation is to use Google Gemini 2.5 Pro, as it provides the best results for the upgrade.