承接 fastcomments/laravel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fastcomments/laravel

Composer 安装命令:

composer require fastcomments/laravel

包简介

Laravel integration for FastComments — Blade components, SSO, and API access

README 文档

README

A Laravel package that wraps the FastComments PHP SDK and SSO library, providing Blade components, SSO integration, and full API access.

Requirements

  • PHP 8.1+
  • Laravel 10, 11, or 12

Installation

composer require fastcomments/laravel

Publish the configuration file:

php artisan vendor:publish --tag=fastcomments-config

Add your credentials to .env:

FASTCOMMENTS_TENANT_ID=your-tenant-id
FASTCOMMENTS_API_KEY=your-api-key

For EU region:

FASTCOMMENTS_REGION=eu

Blade Components

Comment Widget

<x-fastcomments />

{{-- With options --}}
<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" />

Comment Count

<x-fastcomments-comment-count url-id="my-page-id" />
<x-fastcomments-comment-count url-id="my-page-id" :number-only="true" />

SSO

Enable SSO in your .env:

FASTCOMMENTS_API_KEY=your-api-key
FASTCOMMENTS_SSO_ENABLED=true
FASTCOMMENTS_SSO_MODE=secure

The API key is required for secure SSO — it is used to sign the SSO payload.

Config-Based Mapping

In config/fastcomments.php, map FastComments fields to your User model attributes:

'sso' => [
    'enabled' => true,
    'mode' => 'secure',
    'user_map' => [
        'id' => 'id',
        'email' => 'email',
        'username' => 'name',
        'avatar' => 'profile.avatar_url', // dot notation supported
    ],
    'is_admin' => fn ($user) => $user->hasRole('admin'),
    'is_moderator' => fn ($user) => $user->hasRole('moderator'),
],

Interface-Based Mapping

For more control, implement the MapsToFastCommentsUser interface on your 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'),
        ];
    }
}

When the interface is implemented, it takes precedence over config-based mapping.

SSO in Blade

When SSO is enabled, the <x-fastcomments /> component automatically injects SSO data for the authenticated user.

API Access

Via Facade

use FastComments\Laravel\Facades\FastComments;

// Admin API (requires API key)
$comments = FastComments::admin()->getComments('tenant-id');

// Public API
$comments = FastComments::publicApi()->getCommentsPublic('tenant-id', 'url-id');

// SSO
$ssoPayload = FastComments::sso()->forWidget();
$token = FastComments::sso()->tokenFor($user);

Via Dependency Injection

use FastComments\Laravel\FastCommentsManager;

class CommentController extends Controller
{
    public function index(FastCommentsManager $fc)
    {
        $comments = $fc->admin()->getComments($fc->tenantId());
        // ...
    }
}

Direct SDK Access

use FastComments\Client\Api\DefaultApi;

class CommentController extends Controller
{
    public function index(DefaultApi $api)
    {
        $comments = $api->getComments('tenant-id');
        // ...
    }
}

Configuration Reference

Key Env Variable Default Description
tenant_id FASTCOMMENTS_TENANT_ID '' Your FastComments tenant ID
api_key FASTCOMMENTS_API_KEY '' API key for server-side calls
region FASTCOMMENTS_REGION null null (US) or 'eu'
sso.enabled FASTCOMMENTS_SSO_ENABLED false Enable SSO
sso.mode FASTCOMMENTS_SSO_MODE 'secure' 'secure' or 'simple'
sso.login_url FASTCOMMENTS_SSO_LOGIN_URL null Login URL (falls back to Laravel route)
sso.logout_url FASTCOMMENTS_SSO_LOGOUT_URL null Logout URL (falls back to Laravel route)
widget_defaults [] Default widget config options

Customizing Views

To customize the Blade template:

php artisan vendor:publish --tag=fastcomments-views

Templates will be published to resources/views/vendor/fastcomments/.

License

MIT

fastcomments/laravel 适用场景与选型建议

fastcomments/laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「SSO」 「comments」 「laravel」 「fastcomments」 「live-commenting」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fastcomments/laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fastcomments/laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 fastcomments/laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-02