{"id":24408589,"url":"https://github.com/jenstornell/tinyhooks","last_synced_at":"2026-05-17T19:37:02.631Z","repository":{"id":54650297,"uuid":"151266387","full_name":"jenstornell/TinyHooks","owner":"jenstornell","description":"TinyHooks is perhaps the smallest PHP hook library on earth","archived":false,"fork":false,"pushed_at":"2018-10-03T11:41:58.000Z","size":7,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-20T01:32:34.359Z","etag":null,"topics":["actions","filters","hook","hooks","php","php-hooks"],"latest_commit_sha":null,"homepage":"","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/jenstornell.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}},"created_at":"2018-10-02T14:15:46.000Z","updated_at":"2022-08-08T13:55:24.000Z","dependencies_parsed_at":"2022-08-13T22:50:18.322Z","dependency_job_id":null,"html_url":"https://github.com/jenstornell/TinyHooks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jenstornell/TinyHooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenstornell%2FTinyHooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenstornell%2FTinyHooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenstornell%2FTinyHooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenstornell%2FTinyHooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenstornell","download_url":"https://codeload.github.com/jenstornell/TinyHooks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenstornell%2FTinyHooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33152021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["actions","filters","hook","hooks","php","php-hooks"],"created_at":"2025-01-20T05:52:18.721Z","updated_at":"2026-05-17T19:37:02.590Z","avatar_url":"https://github.com/jenstornell.png","language":"PHP","funding_links":["https://www.paypal.me/DevoneraAB"],"categories":[],"sub_categories":[],"readme":"# TinyHooks\n\n*Version: 1.0*\n\nTinyHooks is perhaps the smallest PHP hook library on earth. Still packed with features.\n\n## Setup\n\n```php\ninclude __DIR__ . '/tinyhooks.php';\n```\n\n## Basic usage\n\n### Set by an anonymous function\n\nThe most basic way to setup a hook is with a anonymus function like below.\n\n```php\nhook::set('myhook', function($args) {\n  return 'Hello ' . $args;\n});\n```\n\n### Trigger\n\nBelow will output `Hello world` on the screen, if you have set the hook like above.\n\n```php\necho hook('myhook', 'world');\n```\n\n## Set by other types\n\n### Function\n\nIf you use a string as a second argument, you will call a function.\n\n```php\nhook::set($name, 'about');\n\nfunction about($args) {\n  // Do something\n}\n```\n\n### Static function\n\nTo call a static function you need to include the class name like below.\n\n```php\nhook::set($name, 'MyStatic::myhook');\n\nclass MyStatic {\n  public static function myhook($args) {\n    // Do something\n  }\n}\n```\n\n### Object function\n\nTo use a function in a class, you need to create an object. Then you need to send the object and the class name as an array, like below.\n\n```php\n$object = new MyClass();\n\nhook::set($name, [$object, 'myhook']);\n\nclass MyClass {\n  function myhook($args) {\n    // Do something\n  }\n}\n```\n\n## Multiple hooks in one go\n\nYou can setup all your hooks with an array. The `key` of every row is the pattern and the `value` is the call. That way it works very similar to the `hook::set()` function.\n\n```php\nhooks::set([\n  [\n    'myhook' =\u003e function($args) {\n      // Do something\n    }\n  ],\n  [\n    'myhook' =\u003e function($args) {\n      // Do something\n    }\n  ]\n]);\n```\n\n## Actions \u0026 filters\n\nYou can use the hooks both as actions or as filters.\n\nIf you want to do something and don't want to return something, it's an action. If you want it to behave more like a filter, then return something from the hook.\n\n## Donate\n\nDonate to [DevoneraAB](https://www.paypal.me/DevoneraAB) if you want.\n\n## Additional notes\n\n- To keep it dead simple, namespaces are not used.\n- In case of collision, you can rename the `hook` class and the `hook` function.\n\n## Requirements\n\n- PHP 7\n\n## Inspiration\n\n- [Kirby CMS hooks](https://getkirby.com/docs/developer-guide/advanced/hooks) Multiple names support idea.\n- [WordPress hooks](https://codex.wordpress.org/Plugin_API#Hook_to_WordPress) Actions and filters.\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenstornell%2Ftinyhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenstornell%2Ftinyhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenstornell%2Ftinyhooks/lists"}