genealabs/laravel-tawk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

genealabs/laravel-tawk

Composer 安装命令:

composer require genealabs/laravel-tawk

包简介

Integrate Tawk.to into yoru Laravel and Nova apps.

README 文档

README

Tawk for Laravel masthead image.

Easily and quickly integrate Tawk.to LiveChat into your laravel app in under 5 minutes!

Features

  • all the default Tawk.to LiveChat features.
  • automatic user identification (for logged-in users).
  • secure chat API (for logged-in users).

Requirements

  • PHP 8.2+
  • Laravel 8.0+

Supported Versions

PHP Laravel
8.2 8.x – 13.x
8.3 8.x – 13.x
8.4 8.x – 13.x
8.5 8.x – 13.x

Installation

composer require "genealabs/laravel-tawk:*"

Configuration

Refer to the Property Settings page in your Tawk.to dashboard for the required values. Add the following to your .env file:

TAWK_API_KEY=xxxxxxxxxxxxxxx
TAWK_SITE_ID=yyyyyyyyyyyyyyy

Implementation

Laravel App

Add the following to your layout blade template immediately before the closing </body> tag:

            @tawk
//      </body>
// </html>

Laravel Nova

If you are using Laravel Nova as a dashboard for your users, first publish the layout blade template, then insert the blade directive immediate prior to the closing </body> tag in resources/views/vendor/nova/layout.blade.php:

            @tawk
//      </body>
// </html>

Troubleshooting

Blank page / Tawk widget not appearing

  1. Check your .env values: Ensure TAWK_SITE_ID and TAWK_API_KEY are set correctly. You can find these in your Tawk.to dashboard under Property Settings.
  2. Clear config cache: Run php artisan config:clear after updating .env.
  3. Check the HTML source: View your page source and look for the Tawk.to script tag. If it's missing entirely, the @tawk directive may not be in your layout. If it shows a comment about missing TAWK_SITE_ID, update your .env.
  4. Check browser console: Open the browser developer tools console for JavaScript errors.
  5. Verify the directive placement: The @tawk directive must be placed immediately before the closing </body> tag in your layout blade template.

Console Capture

To automatically send the visitor's browser console output (errors, warnings, logs) to Tawk.to when a chat starts, add the following to your .env:

TAWK_CAPTURE_CONSOLE=true

When enabled, the last 50 console entries are captured and sent as custom attributes when a visitor initiates a chat. This includes:

  • Console errors, warnings, and logs
  • Unhandled JavaScript errors
  • Unhandled promise rejections

The data appears in the Tawk.to agent dashboard as custom visitor attributes.

Screenshot Capture

To automatically take a screenshot of the page when a visitor starts a chat, add the following to your .env:

TAWK_CAPTURE_SCREENSHOT=true

When enabled, html2canvas (loaded from CDN) captures the visible page and sends it as a Tawk.to custom attribute. The screenshot appears in the agent dashboard as a base64 JPEG image.

Note: Screenshots are compressed (50% scale, 60% JPEG quality) to stay within Tawk.to's attribute size limits. Very large pages may exceed the limit and the screenshot will be skipped.

genealabs/laravel-tawk 适用场景与选型建议

genealabs/laravel-tawk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.24k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2019 年 08 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-24