Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/takuya/php-laravel-mattermost-post
post mattermost by bot account api as laravel plugin
https://github.com/takuya/php-laravel-mattermost-post
Last synced: 21 days ago
JSON representation
post mattermost by bot account api as laravel plugin
- Host: GitHub
- URL: https://github.com/takuya/php-laravel-mattermost-post
- Owner: takuya
- License: mit
- Created: 2022-08-12T06:53:55.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-08-12T08:34:02.000Z (over 2 years ago)
- Last Synced: 2024-10-13T18:54:37.926Z (about 1 month ago)
- Language: PHP
- Size: 10.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-mattermost-post
post mattermost by bot account api as laravel plugin## Installing
```shell
cd your-laravel-project
composer config repositories.'php-laravel-mattermost-post' \
vcs https://github.com/takuya/php-laravel-mattermost-post.git
composer require takuya/php-laravel-mattermost-post:master
composer install```
## Using
```shell
php artisan make:notification SampleNotify
php artisan make:command MattermostNotifySample
```
### app/Notifications/SampleNotify.php
```php
content( "@takuya Sample notify" );
return $msg;
}
}
```
### app/Console/Commands/MattermostNotifySample.php
```php
notify( new SampleNotify() );
return 0;
}
}
```
### .env
```php
MATTERMOST_BOT_ID=ujkaXXXXXXXXXXXXX
MATTERMOST_BOT_TOKEN=oxjnXXXXXXXX
MATTERMOST_URL=https://mm.exmample.com/
MATTERMOST_CHANNEL_ID=dkt9gqXXXXXXXXXXX
```
### config/mattermost.php
```php
env( 'MATTERMOST_CHANNEL_ID' ),
'token' => env( 'MATTERMOST_BOT_TOKEN' ),
'bot_id' => env( 'MATTERMOST_BOT_ID' ),
'host' => env( 'MATTERMOST_URL' ),
];
```
### run
```
php artisan mm:notify
```### result
![](https://user-images.githubusercontent.com/55338/184316220-e6d78dc0-3908-4c6a-9647-9684a9b59ff9.png)
### result with formatting
![](https://user-images.githubusercontent.com/55338/184316742-c1257e71-0fc5-4c98-9afd-965f63542aa0.png)## Testing
```shell
## clone
git clone https://github.com/takuya/php-laravel-mattermost-post.git
cd php-laravel-mattermost-post
composer install
## prepare
export MATTERMOST_BOT_TOKEN=XXXXXoxjno3dXXXX
export MATTERMOST_URL=https://mm.exmaple.com/
export MATTERMOST_CHANNEL_ID=XXXXdkt9gXXXX
## post
vendor/bin/phpunit --filter testPostMattermostChannel_FormattedText
```