214 lines
No EOL
5.2 KiB
Markdown
214 lines
No EOL
5.2 KiB
Markdown
# Domain Configuration Integration - Claude v2
|
|
|
|
## 🎯 Überblick
|
|
|
|
Die Claude v2 SubdomainResolver-Middleware wurde erweitert, um die `config/domains.php` Konfigurationsdatei zu verwenden. Dies sorgt für eine zentrale, wartbare Domain-Konfiguration.
|
|
|
|
## 📁 Unterstützte Domain-Typen aus config/domains.php
|
|
|
|
### 1. Main Domain (`main`)
|
|
```php
|
|
'main' => [
|
|
'host' => 'mivita.care',
|
|
'type' => 'main',
|
|
]
|
|
```
|
|
- **Verhalten**: Keine Shop-Daten, normale Corporate Website
|
|
- **Session**: `.mivita.care`
|
|
- **Routing**: `routes/domains/main.php`
|
|
|
|
### 2. Shop Domain (`shop`)
|
|
```php
|
|
'shop' => [
|
|
'host' => 'mivita.shop',
|
|
'type' => 'main-shop',
|
|
'default_user_shop' => 'aloevera',
|
|
]
|
|
```
|
|
- **Verhalten**: Lädt Default-Shop (aloevera) aus Konfiguration
|
|
- **Session**: `.mivita.shop`
|
|
- **Routing**: `routes/domains/shop.php`
|
|
|
|
### 3. CRM Domain (`crm`)
|
|
```php
|
|
'crm' => [
|
|
'host' => 'my.mivita.care',
|
|
'type' => 'crm',
|
|
]
|
|
```
|
|
- **Verhalten**: CRM-Interface, keine Shop-Daten
|
|
- **Session**: `.mivita.care`
|
|
- **Routing**: `routes/domains/crm.php`
|
|
|
|
### 4. Portal Domain (`portal`)
|
|
```php
|
|
'portal' => [
|
|
'host' => 'in.mivita.care',
|
|
'type' => 'portal',
|
|
]
|
|
```
|
|
- **Verhalten**: Partner-Portal, keine Shop-Daten
|
|
- **Session**: `.mivita.care`
|
|
- **Routing**: `routes/domains/portal.php`
|
|
|
|
### 5. Checkout Domain (`checkout`)
|
|
```php
|
|
'checkout' => [
|
|
'host' => 'checkout.mivita.care',
|
|
'type' => 'checkout',
|
|
]
|
|
```
|
|
- **Verhalten**: Behält vorhandene Shop-Session für Checkout
|
|
- **Session**: `.mivita.care`
|
|
- **Routing**: `routes/domains/checkout.php`
|
|
|
|
### 6. User Shop Subdomains (`user-shop`)
|
|
```php
|
|
'user-shop' => [
|
|
'host' => '{subdomain}.mivita.care',
|
|
'type' => 'user-shop',
|
|
]
|
|
```
|
|
- **Verhalten**: Dynamische User-Shops basierend auf Subdomain
|
|
- **Session**: `.mivita.care`
|
|
- **Routing**: `routes/domains/user-shop.php`
|
|
|
|
## 🔒 Reserved Subdomains
|
|
|
|
Die Konfiguration definiert reservierte Subdomains, die nicht als User-Shops verwendet werden können:
|
|
|
|
```php
|
|
'reserved_subdomains' => [
|
|
'my', // CRM
|
|
'in', // Portal
|
|
'checkout', // Checkout
|
|
'www', // Standard
|
|
'api', // API
|
|
'mail', // Mail
|
|
],
|
|
```
|
|
|
|
## 🏗️ Parsing-Logik
|
|
|
|
### Reihenfolge der Domain-Auflösung:
|
|
|
|
1. **Exakte Übereinstimmungen** - Prüft main, shop, crm, portal, checkout
|
|
2. **User-Shop-Pattern** - Prüft `{subdomain}.mivita.care` Pattern
|
|
3. **Reserved-Check** - Stellt sicher, dass Subdomain nicht reserviert ist
|
|
4. **Unknown Fallback** - Redirect zu main domain
|
|
|
|
### Beispiel-Hosts:
|
|
```php
|
|
'mivita.care' → type: 'main'
|
|
'mivita.shop' → type: 'main-shop'
|
|
'my.mivita.care' → type: 'crm'
|
|
'in.mivita.care' → type: 'portal'
|
|
'checkout.mivita.care' → type: 'checkout'
|
|
'testuser.mivita.care' → type: 'user-shop', subdomain: 'testuser'
|
|
'www.mivita.care' → type: 'unknown' (reserved)
|
|
'unknown.example.com' → type: 'unknown'
|
|
```
|
|
|
|
## ⚙️ Session-Domain-Konfiguration
|
|
|
|
Die Middleware konfiguriert automatisch die richtige Session-Domain:
|
|
|
|
```php
|
|
// Für .care Domains (main, crm, portal, checkout, user-shop):
|
|
Config::set('session.domain', '.mivita.care');
|
|
|
|
// Für .shop Domains:
|
|
Config::set('session.domain', '.mivita.shop');
|
|
```
|
|
|
|
## 🔗 URL-Generation
|
|
|
|
Die Middleware setzt `config('app.url')` für korrekte URL-Generation:
|
|
|
|
```php
|
|
// Beispiele:
|
|
'https://mivita.care'
|
|
'https://mivita.shop'
|
|
'https://testuser.mivita.care'
|
|
'https://my.mivita.care'
|
|
```
|
|
|
|
## 🛠️ Konfiguration anpassen
|
|
|
|
### Environment-Variablen:
|
|
```env
|
|
APP_DOMAIN=mivita
|
|
APP_TLD_CARE=.care
|
|
APP_TLD_SHOP=.shop
|
|
APP_PROTOCOL=https://
|
|
APP_PRE_URL_CRM=my.
|
|
APP_PRE_URL_PORTAL=in.
|
|
APP_URL_CHECKOUT=checkout.
|
|
```
|
|
|
|
### Neue Domain hinzufügen:
|
|
|
|
1. **config/domains.php erweitern:**
|
|
```php
|
|
'new-domain' => [
|
|
'host' => 'new.mivita.care',
|
|
'type' => 'new-domain',
|
|
],
|
|
```
|
|
|
|
2. **SubdomainResolver.php erweitern:**
|
|
```php
|
|
'new-domain' => $this->handleNewDomain($request, $next, $domainInfo),
|
|
```
|
|
|
|
3. **Handler-Methode hinzufügen:**
|
|
```php
|
|
private function handleNewDomain($request, Closure $next, array $domainInfo)
|
|
{
|
|
$this->configureSessionDomain($domainInfo['host']);
|
|
Config::set('app.url', config('domains.protocol') . $domainInfo['host']);
|
|
return $next($request);
|
|
}
|
|
```
|
|
|
|
4. **Route-Datei erstellen:**
|
|
```bash
|
|
touch routes/domains/new-domain.php
|
|
```
|
|
|
|
## 🧪 Testing mit Domain-Config
|
|
|
|
### Test-Szenarien:
|
|
```bash
|
|
# Main Domain
|
|
curl -H "Host: mivita.care" http://localhost/
|
|
|
|
# Shop Domain
|
|
curl -H "Host: mivita.shop" http://localhost/
|
|
|
|
# User Shop
|
|
curl -H "Host: testuser.mivita.care" http://localhost/
|
|
|
|
# CRM
|
|
curl -H "Host: my.mivita.care" http://localhost/
|
|
|
|
# Portal
|
|
curl -H "Host: in.mivita.care" http://localhost/
|
|
|
|
# Checkout
|
|
curl -H "Host: checkout.mivita.care" http://localhost/
|
|
|
|
# Reserved Subdomain (should redirect)
|
|
curl -H "Host: www.mivita.care" http://localhost/
|
|
|
|
# Unknown Domain (should redirect)
|
|
curl -H "Host: unknown.example.com" http://localhost/
|
|
```
|
|
|
|
## ✅ Vorteile der Config-Integration
|
|
|
|
- **Zentrale Verwaltung**: Alle Domains in einer Datei
|
|
- **Umgebungs-spezifisch**: Verschiedene Domains für dev/staging/prod
|
|
- **Erweiterbar**: Neue Domains ohne Code-Änderungen
|
|
- **Validation**: Reserved subdomains verhindern Konflikte
|
|
- **Wartbar**: Klare Struktur und Dokumentation |