{"id":22547093,"url":"https://github.com/kiwilan/php-notifier","last_synced_at":"2026-04-17T12:32:27.873Z","repository":{"id":221576888,"uuid":"754756996","full_name":"kiwilan/php-notifier","owner":"kiwilan","description":"PHP Notifier is a package to send mails or notifications for Discord or Slack.","archived":false,"fork":false,"pushed_at":"2024-03-16T09:55:26.000Z","size":203,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-03-16T11:22:59.981Z","etag":null,"topics":["discord","mail","notification","notifier","slack","webhook"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/kiwilan/php-notifier","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/kiwilan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":"kiwilan"}},"created_at":"2024-02-08T17:57:15.000Z","updated_at":"2024-04-15T09:33:35.061Z","dependencies_parsed_at":"2024-03-16T10:58:43.795Z","dependency_job_id":"701f22a9-14b1-429b-b5f6-59aba8c3f37f","html_url":"https://github.com/kiwilan/php-notifier","commit_stats":null,"previous_names":["kiwilan/php-notifier"],"tags_count":12,"template":false,"template_full_name":"spatie/package-skeleton-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwilan%2Fphp-notifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwilan%2Fphp-notifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwilan%2Fphp-notifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwilan%2Fphp-notifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiwilan","download_url":"https://codeload.github.com/kiwilan/php-notifier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245999597,"owners_count":20707568,"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":["discord","mail","notification","notifier","slack","webhook"],"created_at":"2024-12-07T15:10:07.133Z","updated_at":"2026-04-17T12:32:22.837Z","avatar_url":"https://github.com/kiwilan.png","language":"PHP","funding_links":["https://github.com/sponsors/kiwilan"],"categories":[],"sub_categories":[],"readme":"# **PHP Notifier**\n\n![Banner with british letter box picture in background and Notifier title](https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg)\n\n[![php][php-version-src]][php-version-href]\n[![version][version-src]][version-href]\n[![downloads][downloads-src]][downloads-href]\n[![license][license-src]][license-href]\n[![tests][tests-src]][tests-href]\n[![codecov][codecov-src]][codecov-href]\n\nPHP Notifier is a package to send mails or notifications for Discord or Slack.\n\n\u003e [!IMPORTANT]\n\u003e This package does not support push notifications or SMS (if you interested, a PR is welcome).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require kiwilan/php-notifier\n```\n\n\u003e [!NOTE]\n\u003e For Laravel, you can use [`kiwilan/notifier-laravel`](https://github.com/kiwilan/notifier-laravel) package.\n\n## Usage\n\nThis package offer a support for Discord and Slack webhooks, and emails with `symfony/mailer`.\n\n-   [Discord](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks): support message and rich embeds webhooks.\n-   [Slack](https://api.slack.com/messaging/webhooks): support message and attachments webhooks (without legacy API support).\n-   Mail: support message and attachments with [`symfony/mailer`](https://symfony.com/doc/current/mailer.html).\n\n### Discord\n\nYou can send simple message, with user and avatar. Default user and avatar will be webhook's name and avatar.\n\n```php\nuse Kiwilan\\Notifier\\Notifier;\n\n$notifier = new Notifier();\n$discord = $notifier-\u003ediscord('https://discord.com/api/webhooks/1234567890/ABCDEFGHIJKLMN0123456789')\n    -\u003emessage('Hello, Discord!')\n    -\u003euser('Notifier', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')\n    -\u003esend();\n```\n\nYou can also send rich embeds.\n\n![discord-rich-embed](./docs/discord-rich-embed.jpg)\n\n```php\nuse Kiwilan\\Notifier\\Notifier;\n\n$notifier = new Notifier();\n$discord = $notifier-\u003ediscord($webhook)\n    -\u003erich('Rich advanced')\n    -\u003etitle('Notifier')\n    -\u003euser('Notifier', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')\n    -\u003eurl('https://ewilan-riviere.com')\n    -\u003eauthor('Author', 'https://ewilan-riviere.com', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')\n    -\u003ecolor('#3498db')\n    -\u003etimestamp()\n    -\u003efields([\n        ['name' =\u003e 'Field 1', 'value' =\u003e 'Value 1'],\n        ['name' =\u003e 'Field 2', 'value' =\u003e 'Value 2'],\n    ], inline: true)\n    -\u003ethumbnail('https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')\n    -\u003eimage('https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')\n    -\u003efooter('Footer', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')\n    -\u003esend();\n```\n\n### Mail\n\nMail use `symfony/mailer` to send emails.\n\n```php\nuse Kiwilan\\Notifier\\Notifier;\n\n$notifier = new Notifier();\n$mailConfig = $notifier-\u003email('smtp')\n    -\u003emailer('smtp')\n    -\u003ehost('mailpit')\n    -\u003eport(1025)\n    -\u003eusername(null)\n    -\u003epassword(null)\n    -\u003eencryption('tls');\n```\n\n```php\n$mailConfig-\u003efrom('hello@example.com', 'Hello')\n    -\u003eto('to@example.com', 'To')\n    -\u003esubject('Hello, Mail!')\n    -\u003emessage('Hello, Mail!')\n    -\u003ehtml('\u003ch1\u003eHello, Mail!\u003c/h1\u003e')\n    -\u003esend();\n```\n\n\u003e [!NOTE]\n\u003e If `html` is not set, `message` will be used as HTML content. And if `html` is set but not `message`, `html` will be used as plain text content with `strip_tags` method.\n\nMultiple recipients can be added with `to` method.\n\n```php\nuse Symfony\\Component\\Mime\\Address;\n\n$mailConfig-\u003efrom('hello@example.com', 'Hello')\n    -\u003eto([\n      new Address('to1@example.com', 'To1'),\n      new Address('to2@example.com', 'To2'),\n    ])\n    -\u003esend();\n```\n\nYou can add attachments with `addAttachment` method.\n\n```php\n$mailConfig-\u003eaddAttachment('path/to/file.txt', 'file.txt')\n    -\u003esend();\n```\n\n### Slack\n\nYou can send simple message.\n\n```php\nuse Kiwilan\\Notifier\\Notifier;\n\n$notifier = new Notifier();\n$slack = $notifier-\u003eslack('https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX')\n    -\u003emessage('Hello, Slack!')\n    -\u003esend();\n```\n\nYou can also send attachments.\n\n```php\nuse Kiwilan\\Notifier\\Notifier;\n\n$notifier = new Notifier();\n$slack = $notifier-\u003eslack($webhook)\n    -\u003eattachment('*Hello, Slack!*')\n    -\u003ecolor('#36a64f')\n    -\u003epretext('Optional pre-text that appears above the attachment block')\n    -\u003eauthor('Kiwilan', 'https://github.com/kiwilan')\n    -\u003etitle('php-notifier', 'https://github.com/kiwilan/php-notifier')\n    -\u003etext('Optional text that appears within the attachment')\n    -\u003efields([\n        [\n            'title' =\u003e 'Priority',\n            'value' =\u003e 'High',\n            'short' =\u003e false,\n        ],\n        [\n            'title' =\u003e 'Priority',\n            'value' =\u003e 'High',\n            'short' =\u003e false,\n        ],\n    ])\n    -\u003eimageUrl('https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')\n    -\u003efooter('Slack API', 'https://raw.githubusercontent.com/kiwilan/php-notifier/main/docs/banner.jpg')\n    -\u003etimestamp(new DateTime())\n    -\u003esend();\n```\n\n### HTTP\n\nYou can use `http` method to send HTTP request.\n\n```php\nuse Kiwilan\\Notifier\\Notifier;\n\n$notifier = new Notifier();\n$http = $notifier-\u003ehttp('https://jsonplaceholder.typicode.com/posts')\n    -\u003emethod('POST')\n    -\u003esend();\n\n$statusCode = $http-\u003egetStatusCode();\n$body = $http-\u003egetResponseBody();\n$headers = $http-\u003egetResponseHeaders();\n```\n\n### Client\n\nHTTP requests use native stream context to send data, `curl` and `guzzle` can be used as option (default is `stream`).\n\n\u003e [!WARNING]\n\u003e If you use `guzzle`, you need to install `guzzlehttp/guzzle` package.\n\n```php\nuse Kiwilan\\Notifier\\Notifier;\n\n$notifier = new Notifier();\n\n$stream = $notifier-\u003eclient('stream') // default\n    -\u003ediscord($webhook)\n    -\u003emessage('Hello, Discord!')\n    -\u003esend();\n\n$curl = $notifier-\u003eclient('curl') // use curl instead of stream\n    -\u003ediscord($webhook)\n    -\u003emessage('Hello, Discord!')\n    -\u003esend();\n\n$guzzle = $notifier-\u003eclient('guzzle') // use guzzle instead of stream (need guzzlehttp/guzzle package)\n    -\u003ediscord($webhook)\n    -\u003emessage('Hello, Discord!')\n    -\u003esend();\n```\n\nTo know if request is successful, you can use `isSuccess` method.\n\n```php\n$notifier = new Notifier();\n\n$discord = $notifier-\u003ediscord($webhook)\n    -\u003emessage('Hello, Discord!')\n    -\u003esend();\n\nif ($discord-\u003eisSuccess()) {\n    echo 'Message sent!';\n}\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n-   [Ewilan Rivière](https://github.com/ewilan-riviere)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[\u003cimg src=\"https://user-images.githubusercontent.com/48261459/201463225-0a5a084e-df15-4b11-b1d2-40fafd3555cf.svg\" height=\"120rem\" width=\"100%\" /\u003e](https://github.com/kiwilan)\n\n[version-src]: https://img.shields.io/packagist/v/kiwilan/php-notifier.svg?style=flat-square\u0026colorA=18181B\u0026colorB=777BB4\n[version-href]: https://packagist.org/packages/kiwilan/php-notifier\n[php-version-src]: https://img.shields.io/static/v1?style=flat-square\u0026label=PHP\u0026message=v8.1\u0026color=777BB4\u0026logo=php\u0026logoColor=ffffff\u0026labelColor=18181b\n[php-version-href]: https://www.php.net/\n[downloads-src]: https://img.shields.io/packagist/dt/kiwilan/php-notifier.svg?style=flat-square\u0026colorA=18181B\u0026colorB=777BB4\n[downloads-href]: https://packagist.org/packages/kiwilan/php-notifier\n[license-src]: https://img.shields.io/github/license/kiwilan/php-notifier.svg?style=flat-square\u0026colorA=18181B\u0026colorB=777BB4\n[license-href]: https://github.com/kiwilan/php-notifier/blob/main/README.md\n[tests-src]: https://img.shields.io/github/actions/workflow/status/kiwilan/php-notifier/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square\u0026colorA=18181B\n[tests-href]: https://github.com/kiwilan/php-notifier/actions/workflows/run-tests.yml\n[codecov-src]: https://codecov.io/gh/kiwilan/php-notifier/branch/main/graph/badge.svg?token=n85p0OoBu0\n[codecov-href]: https://codecov.io/gh/kiwilan/php-notifier\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwilan%2Fphp-notifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiwilan%2Fphp-notifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwilan%2Fphp-notifier/lists"}