{"id":14983748,"url":"https://github.com/irishdan/notificationbundle","last_synced_at":"2025-04-10T19:40:56.558Z","repository":{"id":56993447,"uuid":"92737371","full_name":"irishdan/NotificationBundle","owner":"irishdan","description":"A bundle for creating notifications and dispatching them to user through various channels","archived":false,"fork":false,"pushed_at":"2019-02-16T02:23:51.000Z","size":195,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T17:15:13.881Z","etag":null,"topics":["mail","nexmo","notifications","pusher","slack-webhook","sms","symfony3","twig"],"latest_commit_sha":null,"homepage":null,"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/irishdan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"Security/PusherChannelVoter.php","support":null}},"created_at":"2017-05-29T12:21:06.000Z","updated_at":"2024-05-30T20:26:44.000Z","dependencies_parsed_at":"2022-08-21T10:40:43.235Z","dependency_job_id":null,"html_url":"https://github.com/irishdan/NotificationBundle","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irishdan%2FNotificationBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irishdan%2FNotificationBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irishdan%2FNotificationBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irishdan%2FNotificationBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/irishdan","download_url":"https://codeload.github.com/irishdan/NotificationBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281414,"owners_count":21077423,"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":["mail","nexmo","notifications","pusher","slack-webhook","sms","symfony3","twig"],"created_at":"2024-09-24T14:07:52.151Z","updated_at":"2025-04-10T19:40:56.537Z","avatar_url":"https://github.com/irishdan.png","language":"PHP","readme":"# NotificationBundle\n\n[![Build Status](https://travis-ci.org/irishdan/NotificationBundle.svg?branch=master)](https://travis-ci.org/irishdan/NotificationBundle)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/irishdan/NotificationBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/irishdan/NotificationBundle/?branch=master)\n\n## Overview\n\nThis NotificationBundle allows for the easy creation and and sending of messages to users or other sources, via multiple channels.\nIts also enables easy broadcasting of data or messages via.\n\nOut of the box with minimal configuration notifications can be sent to single or groups of users,\nvia, email, SMS, slack and websockets (pusher).\n\nCombine this bundle with FoundationInk Bundle to send beautiful html emails for any event\nCombine a pusher channel with [taostr](https://codeseven.github.io/toastr/) for instant and attractive notifications\nCombine a pusher channel and a database channel for simple direct messaging.\n\n## Basic setup\n\nOut of the box, NotificationImage bundle should work with minimal configuration.\n\n### Step 1: Download and enable the bundle\n\nDownload with composer\n```\ncomposer require irishdan/notification-bundle\n```\nEnable the bundle in the kernel\n```php\n// app/AppKernel.php\n\npublic function registerBundles()\n{\n    $bundles = array(\n        // ...\n        new IrishDan\\NotificationBundle\\NotificationBundle(),\n    );\n}\n```\n### Step 2: Configure some Notification Channels\n\nOut of the box the bundle supports several channels, including:\n- [mail](Resources/doc/channels.md#mail) (Email)\n- [database](Resources/doc/channels.md#database)\n- [slack](Resources/doc/channels.md#slack)\n- [nexmo](Resources/doc/channels.md#nexmo) (SMS)\n- [pusher](Resources/doc/channels.md#pusher) (Websockets)\n- [logger](Resources/doc/channels.md#logger)\n\nTo enable a channel simple add its configuration to your config.yml\n\n```yml\n# app/config/config.yml\nnotification:\n    mail:\n        default_sender: 'hi@jim.bob'\n    database:\n        entity: 'AppBundle:Notification'\n    pusher:\n        app_id: \"12\"\n        auth_key: \"1111SECURE222KEY\"\n        secret: \"SeCrEt\"\n        cluster: \"eu\"\n        encrypted: true\n        event: 'notification'\n        channel_name: 'private-direct_' # This is a private channel\n    slack:\n    nexmo:\n        api_key: 7654321\n        api_secret: oiCHOIoi\n        from: \"YourApp\"\n    logger:\n        severity: 'info'\n```\n\nIt's also possible to create [custom channels](Resources/doc/channels.md) or [alter an existing channel's behavior](Resources/doc/channels.md)\n\n### Step 4: Database, Pusher, Nexmo, and Slack channels have additional steps.\n\nSome channels require additional steps\n\n#### Database channel\n\nThe Database channel essentially persists a Doctrine entity to the database. \nA generator is provided to create the entity.\n\n```bash\nphp bin/console notification:create-database-notification \n```\n#### Pusher channel\n[Pusher](https://pusher.com/) is a a third party service with a decent free package. You need valid pusher credendials to use the channel.\n\nThe pusher PHP library is required also. Install with composer\n```bash\ncomposer require pusher/pusher-php-server\n\n```\nIf you are using private channels (HIGHLY RECOMMENDED), the pusher authentication route is needed.\nImport the route into your project\n\n```yml\n# app/config/routing.yml\nnotification_pusher_auth:\n    resource: \"@NotificationBundle/Resources/config/routing.yml\"\n\n```\nPusher requires a javascript library and additional  to interact with pusher channel you have defined. \nTwig functions are provided which generate the required javascript\n\n```twig\n{% block javascripts %}\n    \u003cscript src=\"https://js.pusher.com/4.0/pusher.min.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      \n        // Enable pusher logging - don't include this in production\n        Pusher.logToConsole = true;\n\n        {{ notification_new_pusher_js() }}\n\n        {{ notification_new_pusher_channel_js(app.user) }}\n\n        channel.bind('{{ notification_pusher_event }}', function (data) {\n            // The data object contains your notification data\n            console.log(data);\n            // Add custom js to react to the the notifcation.\n            // A good solution is to use toastr to display the notification.\n        });  \n    \u003c/script\u003e\n{% endblock %}\n\n```\n\n#### Nexmo channel\n\n[Nexmo](https://www.nexmo.com) Is a third party SMS service. You need valid credentials to use this channel.\n\n#### Slack shannel\n\n[Slack](https://slack.com) \n\n### Step 5: Subscribe Users to one or more channels\n\nIn order for users to be sent notifications through the channels you have configured they must be subscribed to each channel.\n\nAssuming your User class is AppBundle\\Entity\\User, implement the required interfaces:\n@TODO: Improve this\n\n```\n\u003c?php\n\nnamespace AppBundle\\Entity;\n\nuse IrishDan\\NotificationBundle\\Notification\\NotifiableInterface;\nuse IrishDan\\NotificationBundle\\PusherableInterface;\nuse IrishDan\\NotificationBundle\\SlackableInterface;\nuse IrishDan\\NotificationBundle\\TextableInterface;\nuse IrishDan\\NotificationBundle\\EmailableInterface;\n\nclass User implements UserInterface, NotifiableInterface, EmailableInterface, TextableInterface, PusherableInterface, SlackableInterface, DatabaseNotifiableInterface\n\n    // For convenience use the\n    use FullyNofifiableTrait();\n\n```\n\n### Step 6: Generate Notification objects\n\nEach Notification is a separate Object. \nSo for example you might have a NewMemberNotification() object and a NewPaymentReceivedNotification() object.\n\nTo create a new Notification object use the provided generator.\n\n```bash\nphp bin/console notification:create\n```\n### Step 7: Edit the Notification content\n\nUses twig...\n\n### Step 8: Send Notifications\n\nTo sent a notification, you need a Recipient.\n\nRecipients are objects that implements NotifiableInterface, created in [step 5]()\nNotifications are objects that implement Notification interface, generated in [step 6]()\n\nNotifications are sent using the 'notification.manager' service like so:\n\n```php\n\u003c?php\n\n/** $user NotifiableInterface */\n$user = $this-\u003egetUser();\n\n/** $notification NotificationInterface */\n$notification = new NewMemberNotification();\n\n// The notification.manager service is used to send notifications\n$this-\u003eget('notification.manager')-\u003esend($notification, $user);\n\n// You can send to multiple users also.\n$this-\u003eget('notification.manager')-\u003esend($notification, [$user1, $user2]);\n\n// You can pass extra data into the notification also\n// This will be available in the data array\n// and also in twig templates as {{ data.date }}\n$data = [\n    'date' =\u003e new \\DateTime(),\n];\n$this-\u003eget('notification.manager')-\u003esend($notification, $user, $data);\n```\n\n## Documentation\n\nFor more advanced setup read the Documentation\n\n- [Installation and Setup](Resources/doc/installation.md)\n- [Channels](Resources/doc/channels.md)\n- [Adapters](Resources/doc/adapters.md)\n- [Broadcast](Resources/doc/broadcast.md)\n- [Events \u0026 Qeueing](Resources/doc/events_queueing.md)\n- [Commands](Resources/doc/commands.md)\n- [Tests](Resources/doc/tests.md)\n   \n    \n## Attribution\n\n- This bundle was inspired by the [Laravel](https://laravel.com/) notification system","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firishdan%2Fnotificationbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firishdan%2Fnotificationbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firishdan%2Fnotificationbundle/lists"}