{"id":13828517,"url":"https://github.com/gpressutto5/laravel-slack","last_synced_at":"2025-07-09T06:32:03.397Z","repository":{"id":44589859,"uuid":"133063168","full_name":"gpressutto5/laravel-slack","owner":"gpressutto5","description":":hash: Slack notification for Laravel as it should be. Easy, fast, simple and highly testable.","archived":true,"fork":false,"pushed_at":"2023-12-27T21:34:44.000Z","size":57,"stargazers_count":289,"open_issues_count":4,"forks_count":41,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-10-20T18:12:38.738Z","etag":null,"topics":["laravel","php","slack","testable"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gpressutto5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-05-11T16:26:31.000Z","updated_at":"2024-07-10T05:30:22.000Z","dependencies_parsed_at":"2023-12-27T03:29:36.822Z","dependency_job_id":"2e36f4cc-3827-4879-a480-e937367f2f81","html_url":"https://github.com/gpressutto5/laravel-slack","commit_stats":{"total_commits":57,"total_committers":8,"mean_commits":7.125,"dds":0.2807017543859649,"last_synced_commit":"ae0aaa8f84bf6806daa0623169c979f7b43b7333"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpressutto5%2Flaravel-slack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpressutto5%2Flaravel-slack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpressutto5%2Flaravel-slack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpressutto5%2Flaravel-slack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gpressutto5","download_url":"https://codeload.github.com/gpressutto5/laravel-slack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225492420,"owners_count":17482869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","php","slack","testable"],"created_at":"2024-08-04T09:02:50.344Z","updated_at":"2024-11-20T08:30:39.423Z","avatar_url":"https://github.com/gpressutto5.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://seeklogo.com/images/S/slack-logo-DE4445077C-seeklogo.com.png\" height=\"60px\"\u003e\u003cimg src=\"https://laravel.com/assets/img/components/logo-laravel.svg\" height=\"60px\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://travis-ci.com/gpressutto5/laravel-slack\"\u003e\u003cimg src=\"https://img.shields.io/travis/com/gpressutto5/laravel-slack/master.svg?style=for-the-badge\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/gpressutto5/laravel-slack\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/github/gpressutto5/laravel-slack/master.svg?style=for-the-badge\" alt=\"codecov\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/gpressutto5/laravel-slack\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/gpressutto5/laravel-slack.svg?style=for-the-badge\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/gpressutto5/laravel-slack\"\u003e\u003cimg src=\"https://img.shields.io/packagist/php-v/gpressutto5/laravel-slack.svg?style=for-the-badge\" alt=\"PHP from Packagist\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/gpressutto5/laravel-slack\"\u003e\u003cimg src=\"https://img.shields.io/badge/laravel-%3E%3D5.5-orange.svg?style=for-the-badge\" alt=\"Laravel Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/gpressutto5/laravel-slack\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/gpressutto5/laravel-slack.svg?style=for-the-badge\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/gpressutto5/laravel-slack\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/gpressutto5/laravel-slack.svg?style=for-the-badge\" alt=\"License\"\u003e\u003c/a\u003e\n\u003cbr\u003e\nBased on \u003ca href=\"https://github.com/illuminate/mail\"\u003eilluminate/mail\u003c/a\u003e\n\u003c/p\u003e\n\n## About Laravel Slack\n\nSlack notification for Laravel as it should be.\nEasy, fast, simple and **highly testable**.\nSince it uses On-Demand Notifications, it requires Laravel 5.5 or higher.\n\n\u003e **This library is archived** and no longer maintained. It works as expected, but I don't have time to maintain it anymore. As a last update, I've removed version constraints from the `composer.json` file, so you can use it with any future Laravel versions. Feel free to fork it and use it as you wish.\n\n## Installation \n\nRequire this package in your composer.json and update your dependencies:\n\n```bash\ncomposer require gpressutto5/laravel-slack\n```\n\nSince this package supports Laravel's Package Auto-Discovery\nyou don't need to manually register the ServiceProvider.\n\nAfter that, publish the configuration file:\n\n```bash\nphp artisan vendor:publish --provider=\"Pressutto\\LaravelSlack\\ServiceProvider\"\n```\n\nYou're gonna need to configure an [\"Incoming Webhook\"](https://api.slack.com/incoming-webhooks) integration for your Slack team.\n\n## Configuration\n\nOn the published configuration file `config/laravel-slack.php`\nyou can change options like the Webhook URL, the default channel,\nthe application name and the application image.\n\nFor security reasons you shouldn't commit your Webhook URL,\nso this package will, by default, use the environment variable\n`SLACK_WEBHOOK_URL`. You can just add it to your `.env` file.\nLike this:\n\n```dotenv\nSLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX\n```\n\n## Usage\n\nYou can send simple Slack messages like this:\n\n- Send message to a channel:\n\n```php\n\\Slack::to('#finance')-\u003esend('Hey, finance channel! A new order was created just now!');\n```\n\n- Send message to an user:\n\n```php\n\\Slack::to('@joe')-\u003esend(\"Hey Joe! It looks like you've forgotten your password! Use this token to recover it: as34bhdfh\");\n```\n\n- Send message to multiple users:\n\n```php\n\\Slack::to(['@zoe', '@amy', '@mia'])-\u003esend('I swear, honey, you are the only one... :heart:');\n//         ↑  look at this array  ↑\n```\n\n- Mix it up:\n\n```php\n\\Slack::to('#universe', '@god', '#scientists')-\u003esend(':thinking_face:');\n//         ↑ what? I don't need that array? ↑\n```\n\n- No recipient:\n\n```php\n\\Slack::send('Default message to the default channel, set on config/laravel-slack.php.');\n```\n\n- Send SlackMessage objects:\n\n```php\nclass HelloMessage extends SlackMessage\n{\n    public $content = \"Hey bob, I'm a sending a custom SlackMessage\";\n    public $channel = '@bob';\n}\n\\Slack::send(new SlackMessage());\n```\n\n- Send to user:\n\n    You can use any object as a recipient as long as they have the\n    property `slack_channel`. If you are using Models you can just\n    create the column `slack_channel` and store the `@username` or\n    the `#channel` name there. If you already store it but on a\n    different column you can create a method `getSlackChannelAttribute`.\n\n```php\nclass User extends Model\n{\n    public function getSlackChannelAttribute(): string\n    {\n        return $this-\u003eattributes['my_custom_slack_channel_column'];\n    }\n}\n\\Slack::to(User::where('verified', true))-\u003esend('Sending message to all verified users!');\n```\n\n- Send message by specifying webhook:\n\n```php\n\\Slack::to('#finance')-\u003ewebhook('https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX')-\u003esend('Hey, finance channel! A new order was created just now!');\n```\n\n## Testing\n\nWhen testing you can easily mock the Slack service by calling\n`Slack::fake()` it will return a `SlackFake` object that won't\nsend any message for real and will save them to an array.\nYou can get this array by calling `Slack::sentMessages()`.\n\nThis class also has some helper methods for you to use when\ntesting:\n\n- Assert that at least one message with the content 'fake' was sent:\n\n```php\nSlack::assertSent(function (SlackMessage $message) {\n    return $message-\u003econtent === 'fake';\n});\n```\n\n- Assert that at least two messages with the content\nbeing a string longer than 5 characters were sent:\n\n```php\nSlack::assertSent(function (SlackMessage $message) {\n    return strlen($message-\u003econtent) \u003e= 100;\n}, 2);\n```\n\n- Assert that exactly five messages where the content\ncontent contains the word 'test' were sent:\n\n```php\nSlack::assertSent(function (SlackMessage $message) {\n    return strpos($message-\u003econtent, 'test') !== false;\n}, 5, true);\n```\n\n- Assert that exactly three messages were sent:\n\n```php\nSlack::assertSentCount(3);\n```\n\nSince this package uses `illuminate/notifications` to send notifications\nyou can mock the Notification service instead of the Slack one\nand use the class `NotificationFake` in your tests.\n[Take a look](https://laravel.com/docs/8.x/mocking#notification-fake).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpressutto5%2Flaravel-slack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgpressutto5%2Flaravel-slack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpressutto5%2Flaravel-slack/lists"}