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: 10 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-12-16T08:31:04.407Z (2 months 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

## 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
```