jeffersongoncalves/laravel-whatsapp-widget 问题修复 & 功能扩展

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

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

jeffersongoncalves/laravel-whatsapp-widget

Composer 安装命令:

composer require jeffersongoncalves/laravel-whatsapp-widget

包简介

This Laravel package provides a simple yet customizable WhatsApp widget for your website. It allows you to easily add a clickable WhatsApp button or floating widget to connect visitors directly with your WhatsApp account. The widget is designed to be easily integrated into your Laravel application a

README 文档

README

Laravel Whatsapp Widget

Laravel Whatsapp Widget

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This Laravel package provides a simple yet customizable WhatsApp widget for your website. It allows you to easily add a clickable WhatsApp button or floating widget to connect visitors directly with your WhatsApp account. The widget is designed to be easily integrated into your Laravel application and is fully customizable to match your website's design.

Features

  • 🚀 Multi-agent support: Add multiple WhatsApp agents with different phone numbers and names
  • ↔️ Side selection: Place the floating widget on the left or right of the screen
  • 🎨 Themeable colors: Customize the button, modal and online status colors via config (no asset rebuild required)
  • 🪟 Modal customization: Control the popup background, text and muted colors independently
  • 🔀 Redirect screen styling: Customize the loading/redirect page background, text, accent and spinner colors
  • 🖼️ Custom icons: Replace the trigger, fallback avatar and redirect icons with your own
  • 🔊 Audio notifications: Optional sound alert when the widget loads (configurable)
  • 📱 Mobile-friendly: Responsive design that works on all devices
  • 🌐 Localization support: Easily translate the widget to any language
  • 🔄 Pre-defined messages: Set default text messages for each agent
  • 🖼️ Custom agent avatars: Add profile pictures for each agent

Screenshots

Widget Position: Right (Default)

Closed Open
Widget Position Right Widget Position Right Open

Widget Position: Left

Closed Open
Widget Position Left Widget Position Left Open

Redirect Page

Redirect Page

Requirements

  • PHP 8.2 or higher
  • Laravel 11.0 or higher

Installation

You can install the package via composer:

composer require jeffersongoncalves/laravel-whatsapp-widget

Usage

1. Publish the package assets

Publish config file:

php artisan vendor:publish --tag=whatsapp-widget-config

Publish migration file:

php artisan vendor:publish --tag=whatsapp-widget-migrations

Publish assets files:

php artisan vendor:publish --tag=whatsapp-widget-assets

Publish translations files:

php artisan vendor:publish --tag=whatsapp-widget-translations

Publish views files:

php artisan vendor:publish --tag=whatsapp-widget-views

2. Run the migrations

php artisan migrate

3. Add the widget to your layout

Add the head template in your layout's <head> section:

@include('whatsapp-widget::whatsapp-widget-head')

Add the body template before the closing </body> tag:

@include('whatsapp-widget::whatsapp-widget-body')

4. Add WhatsApp agents

You need to add WhatsApp agents to your database. You can do this through your application's admin panel or by creating a seeder.

Example seeder:

use JeffersonGoncalves\WhatsappWidget\Models\WhatsappAgent;

WhatsappAgent::create([
    'active' => true,
    'name' => 'Customer Support',
    'phone' => '+1234567890',
    'text' => 'Hello! I have a question about your product.',
    'image' => 'path/to/agent-avatar.jpg', // Optional
]);

Configuration

After publishing the configuration file, you can customize the widget by editing the config/whatsapp-widget.php file:

return [
    // Enable or disable audio notification
    'audio' => true,

    // Play audio notification once per day or on every page load
    'play_audio_daily' => true,

    // Filesystem disk for storing agent images
    'disk' => env('FILESYSTEM_DISK', 'local'),

    // Application URL (used for redirection)
    'url' => env('APP_URL', 'http://localhost'),

    // Application name (displayed in the widget)
    'name' => env('APP_NAME', 'Laravel App'),

    // WhatsApp API key (if needed)
    'key' => env('WHATSAPP_KEY'),

    // Widget position on the screen (left or right)
    'position' => 'right',

    // Colors for the floating button and the modal that opens
    'colors' => [
        'primary' => '#03cc0b',      // Button, modal header and base accents
        'primary_text' => '#ffffff', // Text/icon on top of the primary color
        'badge' => '#ff0000',        // Notification badge background
        'modal_bg' => '#ffffff',     // Modal (popup) background
        'modal_text' => '#000000',   // Agent name / main text inside the modal
        'modal_muted' => '#bababa',  // Secondary / muted text inside the modal
        'online' => '#03cc0b',       // Online status dot and label
    ],

    // Colors for the redirect (loading) screen
    'redirect' => [
        'background' => '#f1f1f1',
        'text' => '#7e7e7e',
        'name' => '#333333',
        'accent' => '#03cc0b',
        'spinner' => '#92d1c3',
    ],

    // Custom icons (null = bundled defaults). Provide a public URL or path.
    'icons' => [
        'trigger' => null,  // Floating button + modal header icon
        'avatar' => null,   // Fallback agent avatar (when an agent has no image)
        'redirect' => null, // Small icon shown on the redirect screen
    ],
];

Customization

Translations

The package currently supports the following languages:

  • 🇸🇦 Arabic (ar)
  • 🇨🇿 Czech (cs)
  • 🇩🇪 German (de)
  • 🇺🇸 English (en)
  • 🇪🇸 Spanish (es)
  • 🇮🇷 Persian (fa)
  • 🇫🇷 French (fr)
  • 🇮🇱 Hebrew (he)
  • 🇮🇩 Indonesian (id)
  • 🇮🇹 Italian (it)
  • 🇯🇵 Japanese (ja)
  • 🇳🇱 Dutch (nl)
  • 🇵🇱 Polish (pl)
  • 🇵🇹 Portuguese (pt)
  • 🇧🇷 Portuguese (Brazil) (pt_BR)
  • 🇵🇹 Portuguese (Portugal) (pt_PT)
  • 🇸🇰 Slovak (sk)
  • 🇹🇷 Turkish (tr)

You can customize the widget's text by editing the translation files in resources/lang/vendor/whatsapp-widget/.

Position

By default, the widget appears in the bottom-right corner of the page. You can change this by modifying the position value in the config/whatsapp-widget.php file.

Example for left position:

'position' => 'left',
Closed Open
Widget Position Left Widget Position Left Open

Example for right position:

'position' => 'right',
Closed Open
Widget Position Right Widget Position Right Open

Colors

The widget and the modal that opens are fully themeable through the colors array in config/whatsapp-widget.php. Colors are applied through CSS custom properties, so changing them does not require rebuilding the assets.

'colors' => [
    'primary' => '#25D366',      // Button, modal header and accents
    'primary_text' => '#ffffff', // Text/icon on top of the primary color
    'badge' => '#ff0000',        // Notification badge background
    'modal_bg' => '#ffffff',     // Modal background
    'modal_text' => '#111111',   // Agent name / main text
    'modal_muted' => '#9aa0a6',  // Secondary text
    'online' => '#25D366',       // Online status dot and label
],

The redirect (loading) screen has its own palette:

'redirect' => [
    'background' => '#f1f1f1',
    'text' => '#7e7e7e',
    'name' => '#333333',
    'accent' => '#25D366',
    'spinner' => '#92d1c3',
],

Icons

You can replace the default icons with your own by pointing the icons array to a public URL or path. Leave a value as null to keep the bundled default.

'icons' => [
    'trigger' => asset('images/my-whatsapp.svg'), // Floating button + modal header
    'avatar' => asset('images/my-avatar.png'),    // Fallback agent avatar
    'redirect' => asset('images/my-icon.png'),    // Redirect screen icon
],

Redirect Page

When a user clicks on an agent, they are redirected to a temporary page before being sent to WhatsApp. Its colors and icon are configurable via the redirect and icons arrays above, and the full page can be further customized by publishing the package views.

Redirect Page

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

jeffersongoncalves/laravel-whatsapp-widget 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 2.94k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 27
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: CSS

其他信息

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