Module editor
title: Module editor description: Editing module files from the panel with the Module editor in AACP: what can be edited, when it is safe, backup and going back.
Modules → Module editor is the module counterpart of the theme editor: you edit a module's source files from the panel without connecting to the server. For a small fix (a translation, a template, a line of CSS) it is much shorter than opening FTP.
This screen requires the system.module.manage capability and changes the module's code. This permission is equivalent to being able to upload a module zip; give it only to administrators you fully trust.
Usage
- Choose the module you want to edit from the Module list (the page refreshes and the file list appears).
- Choose the file from the list on the left. A type label appears next to each file (PHP, TWIG, CSS, JS, YAML, JSON…).
- Edit the file and press Save.
- Before saving, the syntax is checked. If there is a problem, a warning box is shown.
Editable files
php, twig (including .html.twig), css, js, yaml/yml, json, md, txt, sql. The file size is at most 512 KB. The module's vendor/ folder is not listed; the path always stays inside the module's own folder (.. and hidden files starting with a dot are rejected).
Check before saving
| Type | Check | If there is an error |
|---|---|---|
| PHP | PHP syntax (with the parser) | Not saved, cannot be forced |
module.json |
JSON validity | Not saved, cannot be forced |
| JSON, YAML | Validity | Warns; if you confirm it saves anyway |
| Twig | Syntax | Warns; if you confirm it saves |
| CSS, JS | Bracket balance | Warns; if you confirm it saves |
The reason PHP cannot be forced is simple: a parse error in the module class can bring the whole site down on the next request. At boot, module errors are isolated (quarantine), but not saving a broken file in the first place is the safest.
Backup and going back
Before every save, the file's old state is copied under cp-core/var/module-editor/<Module>/ with the name file.ext.YYYYMMDD-HHMMSS.bak. If you broke something, put the backup back on the server under its old name. After the save the cache is cleared; template, translation and route changes are visible immediately.
When not to use it
- If the module will be updated from the store. An edit you make from the panel is overwritten at the module's next update. If you want a lasting change, make it in the module's source and release a new version.
- For big changes. Work spread across several files needs version control, testing and review.
- As a first attempt on a live site. Try locally first.
Running cp:doctor after your edit is a good habit: it verifies that the module is still valid.