Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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