https://github.com/nexylan/slack-bundle
Symfony bundle integration of the nexylan/slack library.
https://github.com/nexylan/slack-bundle
slack symfony symfony-bundle
Last synced: 25 days ago
JSON representation
Symfony bundle integration of the nexylan/slack library.
- Host: GitHub
- URL: https://github.com/nexylan/slack-bundle
- Owner: nexylan
- License: mit
- Created: 2016-03-01T16:05:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-11-26T13:13:15.000Z (over 2 years ago)
- Last Synced: 2025-03-29T07:09:02.747Z (about 1 month ago)
- Topics: slack, symfony, symfony-bundle
- Language: PHP
- Homepage: https://github.com/nexylan/slack
- Size: 68.4 KB
- Stars: 108
- Watchers: 5
- Forks: 22
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# NexySlackBundle
Symfony bundle integration of the [nexylan/slack](https://github.com/nexylan/slack) library (old popular `maknz/slack`).
[](https://packagist.org/packages/nexylan/slack-bundle)
[](https://packagist.org/packages/nexylan/slack-bundle)
[](https://packagist.org/packages/nexylan/slack-bundle)
[](https://www.versioneye.com/php/nexylan:slack-bundle)
[](https://www.versioneye.com/php/nexylan:slack-bundle/references)[](https://packagist.org/packages/nexylan/slack-bundle)
[](https://packagist.org/packages/nexylan/slack-bundle)
[](https://packagist.org/packages/nexylan/slack-bundle)[](https://travis-ci.org/nexylan/NexySlackBundle)
[](https://scrutinizer-ci.com/g/nexylan/NexySlackBundle/?branch=master)
[](https://codeclimate.com/github/nexylan/NexySlackBundle)
[](https://coveralls.io/r/nexylan/NexySlackBundle?branch=master)
[](https://insight.sensiolabs.com/projects/8a6b5dd0-e974-478c-92ee-43125cb7bae3)## Documentation
All the installation and usage instructions are located in this README.
Check it for specific version:* [__1.x__](https://github.com/nexylan/NexySlackBundle/tree/1.x) with support for Symfony `>=2.7`
* [__2.x__](https://github.com/nexylan/NexySlackBundle/tree/master) with support for Symfony `>=3.4`## Prerequisites
This version of the project requires:
* PHP 7.1+
* Symfony 3.4+## Installation
First of all, you need to require this library through composer:
``` bash
$ composer require nexylan/slack-bundle php-http/guzzle6-adapter
```Why `php-http/guzzle6-adapter`? We are decoupled from any HTTP messaging client thanks to [HTTPlug](http://httplug.io/).
Then, enable the bundle on the `AppKernel` class:
``` php
// app/AppKernel.phppublic function registerBundles()
{
$bundles = array(
// ...
new Http\HttplugBundle\HttplugBundle(),
new Nexy\SlackBundle\NexySlackBundle(),
);// ...
return $bundles
}
```## Configuration
If it is not already done, you have to configure httplug-bundle first.
Check the [official documentation](http://docs.php-http.org/en/latest/integrations/symfony-bundle.html) for this.Configure the bundle to your needs (example with default values):
```yaml
nexy_slack:# If you want to use an another httplug client service.
http:
client: httplug.client# The Slack API Incoming WebHooks URL.
endpoint: ~ # Required
channel: null
username: null
icon: null
link_names: false
unfurl_links: false
unfurl_media: true
allow_markdown: true
markdown_in_attachments: []
```Excepted `endpoint`, all the other configuration keys are related to the Slack client default settings.
All those settings are described on the [nexylan/slack documentation](https://github.com/nexylan/slack#settings).
## Usage
The Slack client instance can be retrieved from the `nexy_slack.client` service.
Here is an example:
```php
get('nexy_slack.client');$message = $slack->createMessage();
$message
->to('#test')
->from('John Doe')
->withIcon(':ghost:')
->setText('This is an amazing message!')
;$message->attach((new Attachment())
->setFallback('Some fallback text')
->setText('The attachment text')
);$slack->sendMessage($message);
}
}
```All the how to manipulate the Slack client is on the [nexylan/slack documentation](https://github.com/nexylan/slack#sending-messages).