107 lines
2.9 KiB
Markdown
107 lines
2.9 KiB
Markdown
# Multi-Domain-Konfiguration für Laravel
|
|
|
|
Dieses Projekt unterstützt mehrere Domains mit unterschiedlichen Styles und Konfigurationen.
|
|
Die Domains werden über `.env`-Variablen konfiguriert.
|
|
|
|
## Basis-Konfiguration
|
|
|
|
Füge die folgenden Variablen zu deiner `.env`-Datei hinzu:
|
|
|
|
```env
|
|
# Domain-Konfigurationen
|
|
DOMAIN_ADMIN=portal.b2in.local
|
|
DOMAIN_ADMIN_NAME="Admin Portal"
|
|
|
|
DOMAIN_MAIN=b2in.local
|
|
DOMAIN_MAIN_NAME="B2in"
|
|
|
|
DOMAIN_LANDING1=landing1.local
|
|
DOMAIN_LANDING1_NAME="Landing 1"
|
|
DOMAIN_LANDING1_PRIMARY="#4f46e5"
|
|
DOMAIN_LANDING1_ACCENT="#f59e0b"
|
|
|
|
DOMAIN_LANDING2=landing2.local
|
|
DOMAIN_LANDING2_NAME="Landing 2"
|
|
DOMAIN_LANDING2_PRIMARY="#0d9488"
|
|
DOMAIN_LANDING2_ACCENT="#ec4899"
|
|
|
|
# Entwicklungseinstellungen für Domains
|
|
DEV_SIMULATE_DOMAIN=false
|
|
DEV_SIMULATED_DOMAIN=b2in.local
|
|
```
|
|
|
|
## Entwicklungsmodus
|
|
|
|
Während der Entwicklung kann es nützlich sein, verschiedene Domains zu simulieren,
|
|
ohne die Host-Datei bearbeiten zu müssen:
|
|
|
|
1. Setze `DEV_SIMULATE_DOMAIN=true` in deiner `.env`-Datei.
|
|
2. Setze `DEV_SIMULATED_DOMAIN` auf eine der konfigurierten Domains (z.B. `landing1.local`).
|
|
|
|
Dies bewirkt, dass die Anwendung so reagiert, als würde sie unter der angegebenen Domain laufen,
|
|
unabhängig von der tatsächlichen URL.
|
|
|
|
## Domain-spezifische Konfiguration
|
|
|
|
Jede Domain kann eigene Einstellungen haben:
|
|
|
|
### Admin-Portal (portal.b2in.local)
|
|
|
|
- `DOMAIN_ADMIN`: Die Domain für den Admin-Bereich
|
|
- `DOMAIN_ADMIN_NAME`: Der Name des Admin-Bereichs
|
|
|
|
### Haupt-Website (b2in.local)
|
|
|
|
- `DOMAIN_MAIN`: Die Domain für die Haupt-Website
|
|
- `DOMAIN_MAIN_NAME`: Der Name der Haupt-Website
|
|
|
|
### Landing-Page 1 (landing1.local)
|
|
|
|
- `DOMAIN_LANDING1`: Die Domain für Landing-Page 1
|
|
- `DOMAIN_LANDING1_NAME`: Der Name der Landing-Page 1
|
|
- `DOMAIN_LANDING1_PRIMARY`: Die primäre Farbe im HEX-Format (z.B. `#4f46e5`)
|
|
- `DOMAIN_LANDING1_ACCENT`: Die Akzentfarbe im HEX-Format (z.B. `#f59e0b`)
|
|
|
|
### Landing-Page 2 (landing2.local)
|
|
|
|
- `DOMAIN_LANDING2`: Die Domain für Landing-Page 2
|
|
- `DOMAIN_LANDING2_NAME`: Der Name der Landing-Page 2
|
|
- `DOMAIN_LANDING2_PRIMARY`: Die primäre Farbe im HEX-Format (z.B. `#0d9488`)
|
|
- `DOMAIN_LANDING2_ACCENT`: Die Akzentfarbe im HEX-Format (z.B. `#ec4899`)
|
|
|
|
## Hosts-Datei konfigurieren
|
|
|
|
Um die verschiedenen Domains lokal zu testen, füge folgende Zeilen zu deiner Hosts-Datei hinzu:
|
|
|
|
```
|
|
127.0.0.1 portal.b2in.local
|
|
127.0.0.1 b2in.local
|
|
127.0.0.1 landing1.local
|
|
127.0.0.1 landing2.local
|
|
```
|
|
|
|
Die Hosts-Datei befindet sich unter:
|
|
|
|
- Windows: `C:\Windows\System32\drivers\etc\hosts`
|
|
- macOS/Linux: `/etc/hosts`
|
|
|
|
## Verwendung im Code
|
|
|
|
Im Code kannst du auf die Domain-Konfiguration zugreifen:
|
|
|
|
```php
|
|
// Domain-Name in einem View
|
|
{{ $domainName }}
|
|
|
|
// Theme in einem View
|
|
{{ $theme }}
|
|
|
|
// Vollständige Domain-Konfiguration
|
|
{{ $domainConfig['description'] }}
|
|
|
|
// Über die app-Config
|
|
{{ config('app.theme') }}
|
|
{{ config('app.domain_name') }}
|
|
```
|
|
|
|
Jede Domain lädt automatisch ihr eigenes CSS und andere domainspezifische Assets.
|