Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/takuya/php-laravel-slack-post
slack post by bot account as laravel plugin
https://github.com/takuya/php-laravel-slack-post
Last synced: 21 days ago
JSON representation
slack post by bot account as laravel plugin
- Host: GitHub
- URL: https://github.com/takuya/php-laravel-slack-post
- Owner: takuya
- License: mit
- Created: 2022-08-12T05:16:58.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-08-13T20:13:17.000Z (over 2 years ago)
- Last Synced: 2024-10-13T18:54:34.221Z (about 1 month ago)
- Language: PHP
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-laravel-slack-post
slack post by bot account as laravel plugin## Installing
```sh
composer config repositories.'php-laravel-slack-post' \
vcs https://github.com/takuya/php-laravel-slack-post
composer require takuya/php-laravel-slack-post:master
composer install
```
## Using
```sh
php artisan make:notification SampleNotify
php artisan make:command SlaclNotifySample
```
#### app/Notification/SampleNotify.php
```php
from( $this->username )
->to( $notifiable->getChannelName() )
->content('Hello World');
return $message;
}
}
```
### app/Commands/SlackNotifySample.php```php
notify( new SampleNotify() );
}
}
```
### .env
```
SLACK_TOKEN=xoxb-12xxxxxxxxxxxxxx---xxx
SLACK_CHANNEL_NAME=通知テスト用
SLACK_CHANNEL_ID=C01AXXXXX
```
### config/slack.php
```php
env('SLACK_TOKEN'),
'channel_id'=>env('SLACK_CHANNEL_ID'),
'channel_name'=>env('SLACK_CHANNEL_NAME'),
];
```
### run
```sh
php artisan slack:notify
```### result
![](https://user-images.githubusercontent.com/55338/184298814-74c1e7dd-46e0-407b-9722-a29e93eb093b.png)
## testing
```sh
## prepare
git clone https://github.com/takuya/php-laravel-slack-post
cd php-laravel-slack-post
composer install
## test
export SLACK_TOKEN=xoxb-XXXXX-XXXXXXXXXQoOS5sOv
export SLACK_CHANNEL_NAME='#通知テスト'
export SLACK_CHANNEL_ID=C01AXXXXX
vendor/bin/phpunit --filter testPostSlackChannel
```