{"id":16316498,"url":"https://github.com/bizley/mercure-behavior","last_synced_at":"2025-03-22T21:31:33.519Z","repository":{"id":52379568,"uuid":"210676685","full_name":"bizley/mercure-behavior","owner":"bizley","description":"Yii 2 behavior to automatically publish updates to the Mercure hub","archived":false,"fork":false,"pushed_at":"2024-10-07T04:28:23.000Z","size":19,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T18:45:16.549Z","etag":null,"topics":["behavior","hacktoberfest","mercure","yii2"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bizley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"bizley"}},"created_at":"2019-09-24T18:58:57.000Z","updated_at":"2024-06-04T06:02:22.000Z","dependencies_parsed_at":"2024-10-28T14:56:13.273Z","dependency_job_id":"e2057f72-06cb-4b7b-857a-bfefaf685e7f","html_url":"https://github.com/bizley/mercure-behavior","commit_stats":{"total_commits":7,"total_committers":3,"mean_commits":"2.3333333333333335","dds":0.4285714285714286,"last_synced_commit":"9d9d34b40cac3840335c973af6f082829c765930"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bizley%2Fmercure-behavior","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bizley%2Fmercure-behavior/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bizley%2Fmercure-behavior/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bizley%2Fmercure-behavior/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bizley","download_url":"https://codeload.github.com/bizley/mercure-behavior/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244246521,"owners_count":20422455,"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":["behavior","hacktoberfest","mercure","yii2"],"created_at":"2024-10-10T22:04:49.386Z","updated_at":"2025-03-22T21:31:33.221Z","avatar_url":"https://github.com/bizley.png","language":"PHP","funding_links":["https://github.com/sponsors/bizley"],"categories":[],"sub_categories":[],"readme":"# mercure-behavior\n\n![Latest Stable Version](https://img.shields.io/packagist/v/bizley/mercure-behavior)\n[![Total Downloads](https://img.shields.io/packagist/dt/bizley/mercure-behavior)](https://packagist.org/packages/bizley/mercure-behavior)\n![License](https://img.shields.io/packagist/l/bizley/mercure-behavior)\n\nYii 2 Mercure behavior\n----------------------\n\nThis package provides Yii 2 behavior to automatically publish updates to the Mercure hub when resource is being modified.  \nThe purpose of this behavior is to equip Yii application with the same Mercure functionality as given by \n[API Platform](https://api-platform.com/docs/core/mercure/).\n\nWhat is Mercure?\n----------------\n\nQuoting [dunglas/mercure](https://github.com/dunglas/mercure):\n\u003e Mercure is a protocol allowing to push data updates to web browsers and other HTTP clients in a convenient, fast, \n\u003e reliable and battery-efficient way. It is especially useful to publish real-time updates of resources served through \n\u003e web APIs, to reactive web and mobile apps.\n\nSee the linked repository to find out more about Mercure. There are also instructions how to set up the server and \nthe client to establish connection using Mercure protocol.\n\nInstallation\n------------\n\nAdd the package to your `composer.json`:\n\n    {\n        \"require\": {\n            \"bizley/mercure-behavior\": \"^1.0\"\n        }\n    }\n\nand run `composer update` or alternatively run `composer require bizley/mercure-behavior:^1.0`\n\nYou will of course need Mercure Hub as well. Refer to [dunglas/mercure](https://github.com/dunglas/mercure) for the \ninstructions how to get one (I recommend using Docker image).\n\nUsage\n-----\n\nAdd this [behavior](https://www.yiiframework.com/doc/guide/2.0/en/concept-behaviors) to the resource object you want to \nbe subject of Mercure updates (usually it's an Active Record instance).\n\n```php\nuse \\bizley\\yii2\\behaviors\\mercure\\MercureBehavior;\n\npublic function behaviors()\n{\n    return [\n        MercureBehavior::class,\n    ];\n}\n```\n\nResource object must implement `\\bizley\\yii2\\behaviors\\mercure\\MercureableInterface`.  \nBy default MercureBehavior will dispatch update to Mercure Hub in JSON format after the resource has been\nsuccessfully created, updated, or deleted, using the Mercure publisher component registered under the 'publisher'\nname.\n\nYou can customize the configuration according to your needs, for example:\n\n```php\npublic function behaviors()\n{\n    return [\n        [\n            'class' =\u003e MercureBehavior::class,\n            'publisher' =\u003e \\bizley\\yii2\\mercure\\Publisher::class,\n            'format' =\u003e \\yii\\web\\Response::FORMAT_XML\n        ]\n    ];\n}\n```\n\nPublishing the updates\n----------------------\n\nThe behavior is using [yii2-mercure](https://github.com/bizley/yii2-mercure) package for publishing the updates.  \nPlease follow the repository link to learn how to configure it properly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbizley%2Fmercure-behavior","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbizley%2Fmercure-behavior","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbizley%2Fmercure-behavior/lists"}