{"id":17170323,"url":"https://github.com/nahid/hookr","last_synced_at":"2025-04-13T16:08:01.602Z","repository":{"id":57023326,"uuid":"78082544","full_name":"nahid/hookr","owner":"nahid","description":"PHP action and filter hook system","archived":false,"fork":false,"pushed_at":"2018-10-10T11:46:47.000Z","size":14,"stargazers_count":42,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T16:07:56.285Z","etag":null,"topics":["action","filter","hook","hookr","hooks","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nahid.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-05T05:31:49.000Z","updated_at":"2025-01-30T19:53:35.000Z","dependencies_parsed_at":"2022-08-23T12:20:07.312Z","dependency_job_id":null,"html_url":"https://github.com/nahid/hookr","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nahid%2Fhookr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nahid%2Fhookr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nahid%2Fhookr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nahid%2Fhookr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nahid","download_url":"https://codeload.github.com/nahid/hookr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741206,"owners_count":21154255,"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":["action","filter","hook","hookr","hooks","laravel","php"],"created_at":"2024-10-14T23:29:33.260Z","updated_at":"2025-04-13T16:08:01.581Z","avatar_url":"https://github.com/nahid.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP hookr\n\nA PHP package for action and filter hook. Its helps to you fire any event with your desire action. Its a similar service as WP action and filter.\n  \n## Installation\n\nWrite these command from you terminal.\n\n```shell\ncomposer require nahid/hookr\n```\n\n## Laravel Configuration\n\nAfter complete installation go to `config/app.php` and add this line in providers section\n\n```php\nNahid\\Hookr\\HookrServiceProvider::class,\n```\n\nand add this line in aliases section\n\n```php\n'Hook'  =\u003e  Nahid\\Hookr\\Facades\\Hook::class,\n```\n\nThats all\n\n## Usages\n\n Its so easy to use. Just follow the instruction and apply with your laravel project.\n \n### Action\n\nYou want to extra control with your application without touching your code you apply Action. Suppose you have a blog editor panel. Where you want add extra buttons from others developer without rewrite your code.\nso lets see.\n\n\n  ```html\n  \u003c!-- post.blade.php --\u003e\n  \u003cform\u003e\n      \u003cdiv class=\"form-group\"\u003e\n          \u003clabel for=\"title\"\u003eTitle\u003c/label\u003e\n          \u003cinput type=\"email\" class=\"form-control\" id=\"title\" placeholder=\"Email\"\u003e\n      \u003c/div\u003e\n\n      \u003cdiv class=\"form-group\"\u003e\n          \u003clabel for=\"blog\"\u003eBlog\u003c/label\u003e\n          \u003ctextarea id=\"blog\" cols=\"30\" rows=\"10\" class=\"form-control\"\u003e\u003c/textarea\u003e\n      \u003c/div\u003e\n\n      \u003cbutton type=\"submit\" class=\"btn btn-default\"\u003ePublish\u003c/button\u003e\n      {{hook_action('buttons')}}\n  \u003c/form\u003e\n  ```\n  \n  \n  ![Demo](http://i.imgur.com/xqN1brq.png \"demo\")\n  \n  See, here we use `hook_action()` helper function which is register as named `buttons`\n  So if others developer is want to add more buttons with this form they will do this\n  \n  ```php\n  use Nahid\\Hookr\\Facades\\Hook;\n  \n  class BlogController extends Controller\n  {\n        public function getWritePost()\n        {\n            Hook::bindAction('buttons', function() {\n                echo ' \u003cbutton class=\"btn btn-info\"\u003eDraft\u003c/button\u003e';\n            }, 2);\n            \n            return view('post');\n       }\n  }\n  ```\n  \n  After run this code add new button will add with existing button. \n  \n  \n\n  ![Demo](http://i.imgur.com/Udy1TkG.png \"demo\")\n\n  You can also bind multiple action with this hook. Hookr also support filter. Remind this when you bind multiple filter in a hook then every filter get data from previous filters return data. Suppose you want to add a filter hook in a blog view section.\n\n```\n  \u003ch1\u003e{{$blog-\u003etitle}}\u003c/h1\u003e\n  \u003cp\u003e\n  {{hook_filter('posts', $blog-\u003econtent)}}\n  \u003c/p\u003e\n```\n\nSo we register a filter as 'posts'. Now another developer wants to support markdown for blog posts. so he can bind a filter for parse markdown.\n\n\n ```php\n  use Nahid\\Hookr\\Facades\\Hook;\n  \n  class BlogController extends Controller\n  {\n        public function getPosts()\n        {\n            Hook::bindFilter('posts', function($data) {\n                return parse_markdown($data);\n            }, 2);\n            \n            return view('post');\n       }\n  }\n  ```\n\n  Note: In filter, every callback function must have at least one param which is represent current data\n\n  so if you want to bind multiple data then\n\n   ```php\n  use Nahid\\Hookr\\Facades\\Hook;\n  \n  class BlogController extends Controller\n  {\n        public function getPosts()\n        {\n            Hook::bindFilter('posts', function($data) {\n                return parse_markdown($data);\n            }, 2);\n\n            Hook::bindFilter('posts', function($data) {\n                return parse_bbcode($data);\n            }, 3);\n            \n            return view('post');\n       }\n  }\n  ```\n\n  Now then given data is parse by markdown and bbcode. See, here is second param for `bindFilter()` is a priority for binding. Both `bindAction()` and `bindFilter()` has this feature.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnahid%2Fhookr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnahid%2Fhookr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnahid%2Fhookr/lists"}