Tutorial 2: Shopware Projektstruktur & Entwicklungsumgebung
Was Sie lernen werden
- IDE optimal einrichten (PHPStorm/VSCode)
- Debugging-Workflow aufsetzen
- Code-Quality-Tools integrieren
- Best Practices für die Entwicklung
IDE-Setup: PHPStorm
1. PHPStorm für Shopware konfigurieren
PHP-Interpreter einrichten:
Settings → PHP
- PHP Language Level: 8.2
- CLI Interpreter: /usr/bin/php8.2
Composer installieren:
Settings → PHP → Composer
- Path to composer.json: /pfad/zu/shopware/composer.json
- "composer install" ausführen
Symfony Plugin aktivieren:
Settings → Plugins
- "Symfony Support" installieren
- Plugin aktivieren
- Shopware-Projekt als Symfony-Projekt markieren
2. Xdebug konfigurieren
php.ini anpassen:
ini
[Xdebug]
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_port=9003
xdebug.client_host=127.0.0.1
xdebug.idekey=PHPSTORM
PHPStorm Debug-Konfiguration:
Run → Edit Configurations → Add → PHP Web Page
- Name: "Shopware Storefront"
- Server: localhost:8000
- Start URL: /
Breakpoint setzen & debuggen:
php
<em>// In beliebiger PHP-Datei</em>
public function test(): void
{
$variable = 'test'; <em>// ← Breakpoint hier setzen</em>
dump($variable);
}
3. Nützliche PHPStorm Plugins
- Shopware 6 Toolbox (MUSS!)
- Twig Support
- .env files support
- PHP Annotations
- Database Tools
IDE-Setup: Visual Studio Code
1. Extensions installieren
json
{
"recommendations": [
"bmewburn.vscode-intelephense-client",
"xdebug.php-debug",
"whatwedo.twig",
"mikestead.dotenv",
"EditorConfig.EditorConfig"
]
}
2. settings.json konfigurieren
json
{
"php.suggest.basic": false,
"intelephense.files.associations": [
"*.php",
"*.phtml"
],
"intelephense.files.exclude": [
"**/vendor/**",
"**/var/**"
],
"files.associations": {
"*.twig": "twig"
}
}
3. Xdebug für VSCode
launch.json:
json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
}
}
]
}
Code-Quality-Tools
1. PHP CS Fixer installieren
bash
composer require --dev friendsofphp/php-cs-fixer
.php-cs-fixer.php:
php
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/custom/plugins');
return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
])
->setFinder($finder);
Ausführen:
bash
vendor/bin/php-cs-fixer fix custom/plugins
2. PHPStan einrichten
bash
composer require --dev phpstan/phpstan
phpstan.neon:
neon
parameters:
level: 8
paths:
- custom/plugins
excludePaths:
- */vendor/*
- */Tests/*
Ausführen:
bash
vendor/bin/phpstan analyse
3. Git Hooks einrichten
.git/hooks/pre-commit:
bash
#!/bin/sh
echo "Running PHP CS Fixer..."
vendor/bin/php-cs-fixer fix custom/plugins --dry-run --diff
if [ $? -ne 0 ]; then
echo "❌ Code style errors found. Please fix them before committing."
exit 1
fi
echo "Running PHPStan..."
vendor/bin/phpstan analyse
if [ $? -ne 0 ]; then
echo "❌ PHPStan errors found. Please fix them before committing."
exit 1
fi
echo "✅ All checks passed!"
exit 0
Ausführbar machen:
bash
chmod +x .git/hooks/pre-commit
Development-Workflow Best Practices
1. Branch-Strategie
bash
<em># Feature-Branch erstellen</em>
git checkout -b feature/delivery-time-badge
<em># Arbeiten...</em>
<em># Committen</em>
git add .
git commit -m "feat: Add delivery time badge to product detail page"
<em># Pushen</em>
git push origin feature/delivery-time-badge
2. Commit-Message-Convention
feat: Neue Funktion
fix: Bugfix
docs: Dokumentation
style: Formatierung
refactor: Code-Umstrukturierung
test: Tests
chore: Build/Konfiguration
Beispiele:
feat: Add custom product availability checker
fix: Resolve issue with delivery date calculation
docs: Update plugin installation guide
3. Development-Checklist
Vor jedem Feature:
☐ Branch von main erstellen
☐ Plugin refresh durchführen
☐ Cache leeren
Während der Entwicklung:
☐ Regelmäßig committen
☐ Code-Style prüfen
☐ PHPStan durchlaufen lassen
☐ Funktionalität testen
Vor dem Pushen:
☐ Alle Tests durchlaufen lassen
☐ Cache leeren & neu testen
☐ Code-Review selbst durchführen
☐ CHANGELOG.md aktualisieren
Nützliche Bash-Aliases
~/.bashrc oder ~/.zshrc:
bash
<em># Shopware Aliases</em>
alias sw-clear='bin/console cache:clear'
alias sw-plugin-refresh='bin/console plugin:refresh'
alias sw-theme='bin/console theme:compile'
alias sw-build='./bin/build-storefront.sh && ./bin/build-administration.sh'
alias sw-watch='npm run watch --prefix vendor/shopware/storefront/Resources/app/storefront'
alias sw-log='tail -f var/log/dev.log'
alias sw-test='php vendor/bin/phpunit'
Browser-Extensions für Development
Chrome/Firefox:
- Vue.js DevTools (für Admin-Development)
- Xdebug Helper
- JSON Formatter
- Wappalyzer (Tech-Stack erkennen)
Performance-Monitoring in Development
1. Symfony Profiler nutzen
Profiler-Panel öffnen:
URL aufrufen → Toolbar am unteren Rand → Klick auf Profiler-Icon
Was zu beachten:
- 🔴 Queries > 50: Performance-Problem!
- 🟡 Response Time > 500ms: Optimierung nötig
- 🟢 Response Time < 200ms: Gut!
2. Query-Logging aktivieren
.env.local:
env
DATABASE_URL=mysql://root:root@localhost:3306/shopware?serverVersion=8.0&profileSql=1
Queries in Logs:
bash
tail -f var/log/dev.log | grep "SELECT\|INSERT\|UPDATE"
Fehlerbehebung systematisch angehen
Debug-Workflow
1. Error-Message lesen
↓
2. Stack-Trace analysieren
↓
3. Relevante Datei öffnen
↓
4. Breakpoint setzen
↓
5. Request wiederholen
↓
6. Variablen inspizieren
↓
7. Fix implementieren
↓
8. Testen
Häufige Fehlerquellen
1. Cache-Probleme
bash
bin/console cache:clear
bin/console dal:refresh:index
2. Asset-Probleme
bash
./bin/build-storefront.sh
bin/console theme:compile
3. Autoload-Probleme
bash
composer dump-autoload
bin/console plugin:refresh
4. Datenbankprobleme
bash
bin/console database:migrate --all migrate
bin/console dal:validate
Zusammenfassung
✅ IDE optimal konfiguriert
✅ Debugging-Setup funktioniert
✅ Code-Quality-Tools integriert
✅ Development-Workflow etabliert
Im nächsten Tutorial: Wir erstellen unser erstes echtes Plugin – ein Lieferzeit-Badge-System!

Author: Andreas Lang
Andreas Lang konzentriert sich seit zwei Jahrzehnten auf die Webentwicklung und Webdesign mit dem Schwerpunkt PHP, Laravel und Javascript und betreut seine Kunden mit Herz und Seele in allen Bereichen von Entwicklung, Design, Suchmaschinenoptimierung, IT-Recht, IT-Sicherheit etc.

