
Taal 🇳🇱 Nederlands
Documentatie
Aan de slag
API-referentie
Add Comments to Your Laravel App
Dit is het officiële Laravel-pakket voor FastComments.
Voeg live reacties, chat en meer toe aan uw Laravel-applicatie.
Repository
Installatie 
composer require fastcomments/laravel
Publiceer het configuratiebestand:
php artisan vendor:publish --tag=fastcomments-config
Voeg uw referenties toe aan .env:
FASTCOMMENTS_TENANT_ID=your-tenant-id
FASTCOMMENTS_API_KEY=your-api-key
Voor de EU-regio:
FASTCOMMENTS_REGION=eu
Blade-componenten 
Reactie-widget
<x-fastcomments />
{{-- Met opties --}}
<x-fastcomments
url-id="my-page-id"
url="https://example.com/my-page"
locale="en_us"
:has-dark-background="true"
default-sort-direction="MR"
/>
Livechat
<x-fastcomments-live-chat url-id="chat-room-1" />
Aantal reacties
<x-fastcomments-comment-count url-id="my-page-id" />
<x-fastcomments-comment-count url-id="my-page-id" :number-only="true" />
SSO 
Schakel SSO in je .env-bestand in:
FASTCOMMENTS_API_KEY=your-api-key
FASTCOMMENTS_SSO_ENABLED=true
FASTCOMMENTS_SSO_MODE=secure
De API-sleutel is vereist voor beveiligde SSO — deze wordt gebruikt om de SSO-payload te ondertekenen.
Config-gebaseerde mapping
In config/fastcomments.php map je FastComments-velden naar de attributen van je User-model:
'sso' => [
'enabled' => true,
'mode' => 'secure',
'user_map' => [
'id' => 'id',
'email' => 'email',
'username' => 'name',
'avatar' => 'profile.avatar_url', // puntnotatie ondersteund
],
'is_admin' => fn ($user) => $user->hasRole('admin'),
'is_moderator' => fn ($user) => $user->hasRole('moderator'),
],
Interface-gebaseerde mapping
Voor meer controle implementeer je de MapsToFastCommentsUser-interface op je User-model:
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'),
];
}
}
Wanneer de interface is geïmplementeerd, heeft deze voorrang boven de config-gebaseerde mapping.
SSO in Blade
Wanneer SSO is ingeschakeld, injecteert de <x-fastcomments />-component automatisch SSO-gegevens voor de geauthenticeerde gebruiker.
API-toegang 
Via Facade
use FastComments\Laravel\Facades\FastComments;
// Admin-API (vereist API-sleutel)
$comments = FastComments::admin()->getComments('tenant-id');
// Publieke API
$comments = FastComments::publicApi()->getCommentsPublic('tenant-id', 'url-id');
// SSO
$ssoPayload = FastComments::sso()->forWidget();
$token = FastComments::sso()->tokenFor($user);
Via Dependency-injectie
use FastComments\Laravel\FastCommentsManager;
class CommentController extends Controller
{
public function index(FastCommentsManager $fc)
{
$comments = $fc->admin()->getComments($fc->tenantId());
// ...
}
}
Directe SDK-toegang
use FastComments\Client\Api\DefaultApi;
class CommentController extends Controller
{
public function index(DefaultApi $api)
{
$comments = $api->getComments('tenant-id');
// ...
}
}
Configuratie-referentie 
| Sleutel | Omgevingsvariabele | Standaard | Beschrijving |
|---|---|---|---|
tenant_id |
FASTCOMMENTS_TENANT_ID |
'' |
Uw FastComments tenant-ID |
api_key |
FASTCOMMENTS_API_KEY |
'' |
API-sleutel voor server-side-oproepen |
region |
FASTCOMMENTS_REGION |
null |
null (VS) of 'eu' |
sso.enabled |
FASTCOMMENTS_SSO_ENABLED |
false |
SSO inschakelen |
sso.mode |
FASTCOMMENTS_SSO_MODE |
'secure' |
'secure' of 'simple' |
sso.login_url |
FASTCOMMENTS_SSO_LOGIN_URL |
null |
Login-URL (valt terug op Laravel-route) |
sso.logout_url |
FASTCOMMENTS_SSO_LOGOUT_URL |
null |
Logout-URL (valt terug op Laravel-route) |
widget_defaults |
— | [] |
Standaard widgetconfiguratie-opties |
Hulp nodig?
Als u problemen ondervindt of vragen heeft over het Laravel-pakket, kunt u:
Bijdragen
Bijdragen zijn welkom! Bezoek de GitHub-repository voor richtlijnen voor bijdragen.