juliomotol / laravel-channel-attributes
这是我创建的laravel-channel-attributes包
v1.0.0
2023-01-04 12:37 UTC
Requires
- php: ^8.1
- illuminate/broadcasting: ^9.0
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.13.0
- symfony/finder: ^6.1
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-09 22:48:51 UTC
README
使用注解/属性自动注册通道路由!
本包受到spatie/laravel-route-attributes
的启发。
已经在使用
spatie/laravel-route-attributes
?恭喜你,是时候放弃那个./routes
目录了!(假设你未使用console.php
)
use JulioMotol\ChannelAttributes\Attributes\Channel; #[Channel('foo')] class FooChannel { // }
注册方式如下:
Broadcast::channel('foo', FooChannel::class);
安装
您可以通过composer安装此包
composer require juliomotol/laravel-channel-attributes
您可以使用以下命令发布配置文件:
php artisan vendor:publish --tag="laravel-channel-attributes-config"
这是发布配置文件的内容
return [ /* * Automatic registration of channels will only happen if this setting is `true` */ 'enabled' => true, /* * Channels in these directories that have channel attributes will automatically be registered. * You can specify a different namespace other than `\App` by providing a different key. * * e.g ['\Domain\Post\Broadcasting' => base_path('domain/Post/Broadcasting')] */ 'directories' => [ app_path('Broadcasting'), ], ];
使用方法
要添加自动注册的通道,只需将JulioMotol\ChannelAttributes\Attributes\Channel
添加到通道类中
您可以通过以下方式添加通道选项:
您可以通过以下方式为模型创建通道:
测试
composer test
变更日志
请参阅CHANGELOG以获取有关最近更改的更多信息。
贡献
请参阅CONTRIBUTING以获取详细信息。
安全漏洞
请查阅我们的安全策略以了解如何报告安全漏洞。
鸣谢
许可协议
MIT许可(MIT)。请参阅许可文件以获取更多信息。