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
支持
贡献
有关更多信息,请参阅 贡献。
变更日志
我们保留了一份 变更日志,记录了所有更改的信息。
致谢
版权和许可
版权所有 2018 Bruno Torrinha。Mercurius 采用 MIT 许可证 发布。