Slack Bundle for Symfony
A set of Symfony services for use in your project to ease integration with Slack.
This bundle depends upon the official slack SDK PHP.
Using composer you can simply require master for now until we have a stable release:
$ composer require partfire/slack-bundle:dev-master
Add your details to your
app/config/parameters.yml file. For example:
slack_token: 123456789XXXXXXX slack_username: My-Website slack_team: My-Team slack_testing_channel_name: my-tests-channel
- slack_username: refers to the name that will appear in the channel.
- slack_team: is the team name when you created your team via Slack.
- slack_testing_channel_name refers to the only channel which all messages are sent when the syfony environment is not
prod. This is to allow us to not pollute the other channels for the production environment wehen testing etc.
Also add to your
Send a Message from a controller
$this->container->get('part_fire_slack_service')->sendMessage( "This is an example message", 'some-channel-name', ':muscle:' );
You can also use this service from any other class by simply injecting it if you are using the Symfony DI Container. E.g. you can add the following to the services.yml for your custom class to inject the messaging service:
my_vendor_class_entry_name: class: MyVendor\MyBundle\MyClasses\MyClass arguments: ['@part_fire_slack_service']
Feel free to add more methods to the services etc and create a pull request. I will merge them in if they follow the existing structure or you teach me a better way.