
Sprache 🇩🇪 Deutsch
Dokumentation
Erste Schritte
API-Referenz
Add Comments to Your Laravel App
Dies ist das offizielle Laravel-Paket für FastComments.
Fügen Sie Ihrer Laravel-Anwendung Live-Kommentare, Chat und mehr hinzu.
Repository
Installation 
composer require fastcomments/laravel
Veröffentlichen Sie die Konfigurationsdatei:
php artisan vendor:publish --tag=fastcomments-config
Fügen Sie Ihre Zugangsdaten zur Datei .env hinzu:
FASTCOMMENTS_TENANT_ID=your-tenant-id
FASTCOMMENTS_API_KEY=your-api-key
Für die EU-Region:
FASTCOMMENTS_REGION=eu
Blade-Komponenten 
Kommentar-Widget
<x-fastcomments />
{{-- Mit Optionen --}}
<x-fastcomments
url-id="my-page-id"
url="https://example.com/my-page"
locale="en_us"
:has-dark-background="true"
default-sort-direction="MR"
/>
Live-Chat
<x-fastcomments-live-chat url-id="chat-room-1" />
Kommentaranzahl
<x-fastcomments-comment-count url-id="my-page-id" />
<x-fastcomments-comment-count url-id="my-page-id" :number-only="true" />
SSO 
SSO in Ihrer .env aktivieren:
FASTCOMMENTS_API_KEY=your-api-key
FASTCOMMENTS_SSO_ENABLED=true
FASTCOMMENTS_SSO_MODE=secure
Der API-Schlüssel wird für sicheres SSO benötigt — er wird verwendet, um die SSO-Nutzlast zu signieren.
Konfigurationsbasierte Zuordnung
In config/fastcomments.php ordnen Sie FastComments-Felder den Attributen Ihres User-Modells zu:
'sso' => [
'enabled' => true,
'mode' => 'secure',
'user_map' => [
'id' => 'id',
'email' => 'email',
'username' => 'name',
'avatar' => 'profile.avatar_url', // Punktnotation wird unterstützt
],
'is_admin' => fn ($user) => $user->hasRole('admin'),
'is_moderator' => fn ($user) => $user->hasRole('moderator'),
],
Schnittstellenbasierte Zuordnung
Für mehr Kontrolle implementieren Sie das Interface MapsToFastCommentsUser in Ihrem User-Modell:
use FastComments\Laravel\SSO\Contracts\MapsToFastCommentsUser;
class User extends Authenticatable implements MapsToFastCommentsUser
{
public function toFastCommentsUserData(): array
{
return [
'id' => (string) $this->id,
'email' => $this->email,
'username' => $this->display_name,
'avatar' => $this->avatar_url,
'is_admin' => $this->hasRole('admin'),
];
}
}
Wenn das Interface implementiert ist, hat es Vorrang vor der konfigurationsbasierten Zuordnung.
SSO in Blade
Wenn SSO aktiviert ist, injiziert die Komponente <x-fastcomments /> automatisch SSO-Daten für den authentifizierten Benutzer.
API-Zugriff 
Über Facade
use FastComments\Laravel\Facades\FastComments;
// Admin-API (erfordert einen API-Schlüssel)
$comments = FastComments::admin()->getComments('tenant-id');
// Öffentliche API
$comments = FastComments::publicApi()->getCommentsPublic('tenant-id', 'url-id');
// SSO
$ssoPayload = FastComments::sso()->forWidget();
$token = FastComments::sso()->tokenFor($user);
Über Abhängigkeitsinjektion
use FastComments\Laravel\FastCommentsManager;
class CommentController extends Controller
{
public function index(FastCommentsManager $fc)
{
$comments = $fc->admin()->getComments($fc->tenantId());
// ...
}
}
Direkter SDK-Zugriff
use FastComments\Client\Api\DefaultApi;
class CommentController extends Controller
{
public function index(DefaultApi $api)
{
$comments = $api->getComments('tenant-id');
// ...
}
}
Konfigurationsreferenz 
| Schlüssel | Umgebungsvariable | Standard | Beschreibung |
|---|---|---|---|
tenant_id |
FASTCOMMENTS_TENANT_ID |
'' |
Ihre FastComments Tenant-ID |
api_key |
FASTCOMMENTS_API_KEY |
'' |
API-Schlüssel für serverseitige Aufrufe |
region |
FASTCOMMENTS_REGION |
null |
null (US) oder 'eu' |
sso.enabled |
FASTCOMMENTS_SSO_ENABLED |
false |
SSO aktivieren |
sso.mode |
FASTCOMMENTS_SSO_MODE |
'secure' |
'secure' oder 'simple' |
sso.login_url |
FASTCOMMENTS_SSO_LOGIN_URL |
null |
Login-URL (fällt auf die Laravel-Route zurück) |
sso.logout_url |
FASTCOMMENTS_SSO_LOGOUT_URL |
null |
Logout-URL (fällt auf die Laravel-Route zurück) |
widget_defaults |
— | [] |
Standard-Widget-Konfigurationsoptionen |
| --- |
Benötigen Sie Hilfe?
Wenn Sie auf Probleme stoßen oder Fragen zum Laravel-Paket haben, bitte:
Mitwirken
Beiträge sind willkommen! Bitte besuchen Sie das GitHub-Repository für Richtlinien zur Mitarbeit.