jeffsenso/prestashop-skills / skills/prestashop-module-development
prestashop-module-development
VerifiedComplete PrestaShop module development workflow using modern architecture and best practices. Use when: creating new PrestaShop modules, updating legacy modules to modern code, implementing hooks and actions, setting up module configuration pages, adding front office features, handling database operations, implementing security measures, managing translations, creating cart rules and vouchers, building Symfony console commands, or modernizing existing PrestaShop modules from legacy patterns to current standards.
references/module-structure.md
View on GitHub# Module structure & namespace naming
## Namespace naming convention
Derive the PSR-4 namespace from the module name:
- The module name prefix (first 2 letters before the real words) becomes the **top-level vendor namespace**
- The remaining real words become **sub-namespaces** in CamelCase (detect word boundaries)
- **Never** use the generic `PrestaShop\Module\` vendor prefix — it is reserved for PrestaShop core modules
Examples:
- `mycofeature` → prefix `My`, word `Cofeature` → `My\Cofeature`
- `mycompanycoolfeature` → prefix `My`, words `Company`, `Cool`, `Feature` → `My\CompanyCoolFeature`
- `mycoapp` → prefix `My`, word `Coapp` → `My\Coapp`
This applies to `composer.json` `autoload.psr-4`, PHP `namespace` declarations, and `config/services.yml` FQCNs.
**`composer.json` autoload**:
```json
"autoload": {
"psr-4": { "Vendor\\MyModule\\": "src/" }
}
```
## Standard directory structure
```
mymodule/
├── config/
│ ├── services.yml # Service definitions
│ └── routes.yml # Symfony route definitions
├── src/
│ ├── Controller/ # Symfony controllers
│ │ └── Admin/
│ ├── Form/ # Symfony form types + data providers
│ ├── Grid/ # Grid system (list pages)
│ │ ├── Definition/Factory/
│ │ ├── Filters/
│ │ └── Query/
│ ├── Install/ # Installer classes
│ └── Service/ # Business logic services
├── controllers/ # Legacy controllers (avoid in new code)
├── views/
│ ├── templates/
│ │ ├── admin/ # Admin Twig templates
│ │ ├── front/ # Front office templates
│ │ └── hook/ # Hook Smarty/Twig templates
│ ├── css/
│ ├── js/
│ └── img/
├── upload/ # User-uploaded files (images, documents, etc.)
├── translations/
├── upgrade/ # Module upgrade scripts
├── vendor/ # Composer dependencies
├── config.xml # Cached module properties
├── logo.png # 140x140px module icon
└── mymodule.php # Main module class
```
## Helpful resources
- [PrestaShop Module Generator](https://validator.prestashop.com/generator) — scaffolding for new modules
- [Module good practices](https://devdocs.prestashop-project.org/9/modules/creation/good-practices/)
---
## Upload directory rules
User-uploaded files (images, documents, downloads) **must** be stored in a dedicated directory at the **module root** — never inside `views/`.
```
mymodule/
├── upload/ # ✅ CORRECT — user-uploaded files here
├── views/
│ ├── templates/ # Twig templates only
│ └── img/ # Static module assets only (not user uploads)
```
**Why not `views/`?** The `views/` tree is for Twig templates and static assets bundled with the module. Mixing user uploads into `views/` makes it impossible to distinguish module source files from user data, complicates backups, and can expose template paths to user-controlled filenames.
For Twig namespace overrides (`@PrestaShop` namespace registration via `services.yml`), you will add `views/PrestaShop/` as a path — this is only for template files, never for uploaded content.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |