{"id":14983744,"url":"https://github.com/event-band/band-symfony-bundle","last_synced_at":"2025-08-29T05:07:28.081Z","repository":{"id":36173718,"uuid":"40477832","full_name":"event-band/band-symfony-bundle","owner":"event-band","description":"Symfony2 Bundle for EventBand","archived":false,"fork":false,"pushed_at":"2025-03-20T11:43:15.000Z","size":153,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-16T06:55:25.307Z","etag":null,"topics":["async","asynchronous","bundle","consumer","dispatch","event","event-band","events","listener","rabbit-mq","rabbitmq","rabbitmq-client","rabbitmq-consumer","symfony","symfony2-bundle","symfony3"],"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/event-band.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-08-10T10:56:19.000Z","updated_at":"2025-03-20T11:43:16.000Z","dependencies_parsed_at":"2025-04-10T19:42:42.190Z","dependency_job_id":"156a0264-5dc5-4fdb-a01f-d13f9da4d452","html_url":"https://github.com/event-band/band-symfony-bundle","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/event-band/band-symfony-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/event-band%2Fband-symfony-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/event-band%2Fband-symfony-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/event-band%2Fband-symfony-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/event-band%2Fband-symfony-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/event-band","download_url":"https://codeload.github.com/event-band/band-symfony-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/event-band%2Fband-symfony-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272631708,"owners_count":24967120,"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","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["async","asynchronous","bundle","consumer","dispatch","event","event-band","events","listener","rabbit-mq","rabbitmq","rabbitmq-client","rabbitmq-consumer","symfony","symfony2-bundle","symfony3"],"created_at":"2024-09-24T14:07:51.855Z","updated_at":"2025-08-29T05:07:28.037Z","avatar_url":"https://github.com/event-band.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"EventBandSymfonyBundle\n======================\n\nSymfony2 Bundle for EventBand framework [![Build Status](https://travis-ci.org/event-band/band-symfony-bundle.svg?branch=1.0.x)](https://travis-ci.org/event-band/band-symfony-bundle)\n\n# Quick start\n## Adding event-band to a symfony2 project\nRun the following commands:\n``` bash\n$ composer require \"event-band/symfony-bundle:~1.0\"\n$ composer require \"event-band/amqplib-transport:~1.0\"\n```\n\n## Simple configuration\n### Creating an event\nCreate an event, extending the EventBand\\Adapter\\Symfony\\SerializableSymfonyEvent\n``` php\n\u003c?php\nnamespace Acme\\EventBundle\\Event;\nuse EventBand\\Adapter\\Symfony\\SerializableSymfonyEvent;\n\nclass EchoEvent extends SerializableSymfonyEvent\n{\n    /**\n     * @var string\n     **/\n    protected $message;\n\n    public function __construct($message)\n    {\n        $this-\u003emessage = $message;\n    }\n\n    public funciton getMessage()\n    {\n        return $this-\u003emessage;\n    }\n    \n    protected function toSerializableArray()\n    {\n        $array = parent::toSerializableArray();\n        $array['message'] = $this-\u003emessage;\n\n        return $array;\n    }\n    \n    protected function fromUnserializedArray(array $data)\n    {\n        parent::fromUnserializedArray($data);\n        $this-\u003emessage = $data['message'];\n    }\n}\n```\n### Creating a listener\nThen create a listener\n```php\n\u003c?php\nnamespace Acme\\EventBundle\\Event;\n\nclass EchoEventListener\n{\n    public function onEchoEvent(EchoEvent $event)\n    {\n        // don't do such things on production\n        echo $event-\u003egetMessage();\n        echo \"\\n\";\n    }\n}\n```\nAnd register listener in services.xml\n```xml\n\u003cservice id=\"acme.event_bundle.event.event_listener\" class=\"Acme\\EventBundle\\EchoEventListener\"\u003e\n     \u003ctag name=\"kernel.event_listener\" event=\"event.echo\" method=\"onEchoEvent\"/\u003e\n\u003c/service\u003e\n```\n### Configuring bands\nAdd the following lines to your config.yml\n```yml\nevent_band:\n     publishers:\n         acme.echo.event.publisher:\n             events: [\"event.echo\"]\n             transport:\n                 amqp:\n                     exchange: acme.echo.event.exchange\n     consumers:\n         acme.echo.event: ~\n```\n### Adding band information to listener to make it asynchronous\nAdd parameter `band` with name of consumer to event listener tag to show which consumer it belongs to.\n```xml\n\u003cservice id=\"acme.event_bundle.event.event_listener\" class=\"Acme\\EventBundle\\EchoEventListener\"\u003e\n     \u003ctag name=\"kernel.event_listener\" event=\"event.echo\" method=\"onEchoEvent\" band=\"acme.echo.event\"/\u003e\n\u003c/service\u003e\n```\n### Creating AMQP config\nThis step is not required, but it's very useful to have this config.\nUnder the `event_band` space add the following lines to your config.yml\n```yml\n    transports:\n         amqp:\n             driver: amqplib\n             connections:\n                 default:\n                     exchanges:\n                         acme.echo.event.exchange: ~\n                     queues:\n                         acme.echo.event:\n                             bind:\n                                 acme.echo.event.exchange: ['event.echo']\n```\nNow you can call `app/console event-band:setup amqp:default` command and all the exchanges, queues and bindings will be\nautomatically created/altered.\n### Using asynchronous event\nSomewhere in your code use event dispatcher to dispatch the EchoEvent as you usually do.\n```php\n$dispatcher = $this-\u003egetContainer()-\u003eget('event_dispatcher');\n$dispatcher-\u003edispatch('event.echo', new EchoEvent('Hi, guys!'));\n```\nWhen you run this code, event will be pushed to the acme.echo.event queue.\nNow run console command `event-band:dispatch` with the name of your consumer - `acme.echo.event`.\n```bash\nsh$ app/cosole event-band:dispatch acme.echo.event\nHi, guys!\n```\n...\nProfit.\n\n## Using JMSSerializer\n### Adding dependencies\nRun `composer require \"event-band/jms-serializer:~1.0\"` command\n### Creating an event\n``` php\n\u003c?php\nnamespace Acme\\EventBundle\\Event;\n\nclass EchoEvent implements \\EventBand\\Event\n{\n    /**\n     * @var array\n     * @JMS\\Serializer\\Annotation\\Type(\"array\")\n     */\n    private $data;\n\n    public function __construct($message)\n    {\n        $this-\u003edate['message'] = $message;\n    }\n\n    public function getMessage()\n    {\n        return $this-\u003edata['message'];\n    }\n}\n```\n### Config\nAdd the following lines under 'event_band' section in your config.yml\n```yml\nserializers:\n        serializer:\n            jms:\n                format: json\n```\nAll the other settings are similar.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevent-band%2Fband-symfony-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevent-band%2Fband-symfony-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevent-band%2Fband-symfony-bundle/lists"}