abannova / mercurius
适用于Laravel的实时消息包
Requires
- php: ^7.0
- laravel/framework: ^8.0
- pusher/pusher-php-server: ^3.2
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- mockery/mockery: ^1.0
- orchestra/testbench: ^3.7
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2022-10-15 17:36:42 UTC
README
目录
关于
Mercurius是一个使用Laravel和Vue.js的实时消息系统,它提供了一个完整的可轻松安装的应用程序,适用于任何Laravel项目。
预览

功能
- 实时消息
- 响应式
- 多语言
- 浏览器通知
- 独特的UX,支持暗色主题
- 打字指示器
- 删除对话和消息
- 使用自动完成搜索收件人
截图






演示
您可以在Mercurius演示中尝试。使用以下任一凭据进行认证:
ian@AbanNova.host
noa@AbanNova.host
lua@AbanNova.host
密码: password
提示:打开2个不同的浏览器,并使用不同的用户名登录,以便您可以测试发送/接收消息。
安装
在继续之前,请确保已安装Laravel 5.6
+。
1. 设置Pusher
如果您没有账户,请在pusher.com网站上创建一个免费的账户。转到仪表板,创建一个新的应用并记下API凭证。
现在,让我们将API密钥添加到.env
文件中。同时,将BROADCAST_DRIVER
改为pusher
(默认为log
)。
... BROADCAST_DRIVER=pusher ... PUSHER_APP_ID="xxxxxx" PUSHER_APP_KEY="xxxxxxxxxxxxxxxxxxxx" PUSHER_APP_SECRET="xxxxxxxxxxxxxxxxxxxx" PUSHER_APP_CLUSTER="xx"
2. 注册BroadcastServiceProvider
打开 config/app.php
文件,取消注释 App\Providers\BroadcastServiceProvider::class,
这一行。
3. Laravel 认证
如果认证已经设置,则跳过此步骤,否则输入
php artisan make:auth
4. 安装 Mercurius
composer require AbanNova/mercurius
5. 配置(可选)
如果您想更改默认配置,可以通过输入命令来发布配置文件:
php artisan vendor:publish --tag=mercurius-config
为了编辑配置,打开 /config/mercurius.php
文件并添加您自己的值。
return [ /* |-------------------------------------------------------------------------- | Mercurius Models |-------------------------------------------------------------------------- | | Defines the models used with Mercurius, use it to extend Mercurius and | create your own implementation. | */ 'models' => [ 'user' => App\User::class, 'messages' => AbanNova\Mercurius\Models\Message::class, ], /* |-------------------------------------------------------------------------- | User Table Fields |-------------------------------------------------------------------------- | | You can specify the column names for the user table. The `name` accepts | an array of fields, for building custom names with multiple columns. | */ 'fields' => [ // 'name' => ['first_name', 'last_name'], 'name' => 'name', 'slug' => 'slug', 'avatar' => 'avatar', ], ];
6. 安装 Mercurius
php artisan mercurius:install composer dump-autoload
7. 用户特质
将 AbanNova\Mercurius\MercuriusUser
特质添加到您的 User
模型中
// ... use Illuminate\Foundation\Auth\User as Authenticatable; use AbanNova\Mercurius\MercuriusUser; class User extends Authenticatable { use MercuriusUser; // ... }
8. 安装测试用的虚拟数据
php artisan db:seed --class=MercuriusDatabaseSeeder
将添加消息和用户到系统中,就像在 示例 中一样
演示用户
- Ian:
ian@AbanNova.host
- Noa:
noa@AbanNova.host
- Lua:
lua@AbanNova.host
密码: password
更新 Mercurius
每次更新 Mercurius 时,请确保发布资产以应用新的 CSS/JS 版本。
php artisan vendor:publish --tag=mercurius-public --force
定制
有关更多信息,请参阅 定制。
路线图
有关更多信息,请查看 路线图。
- 单元测试
- 与多个用户的对话 #13
- Webhooks #16
- 上传照片和文件 #14
- 预览图片和视频 #15
- 表情符号支持 #18
- 视频聊天 #19
- 支持 socket.io #20
- 搜索消息 #17
支持
贡献
有关更多信息,请参阅 CONTRIBUTING。
变更日志
我们保留一个 CHANGELOG 记录更改的信息。
鸣谢
版权和许可
版权所有 2018 Bruno Torrinha。Mercurius 在 MIT 许可证下发布。