{"id":21771135,"url":"https://github.com/initphp/events","last_synced_at":"2025-10-16T11:28:30.044Z","repository":{"id":56991535,"uuid":"470091065","full_name":"InitPHP/Events","owner":"InitPHP","description":"Events; are useful constructs that allow you to hook from one point to another within the software.","archived":false,"fork":false,"pushed_at":"2022-07-09T08:55:01.000Z","size":10,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T23:45:01.648Z","etag":null,"topics":["php","php-event","php-hook","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/InitPHP.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":"2022-03-15T09:37:37.000Z","updated_at":"2023-11-11T05:33:46.000Z","dependencies_parsed_at":"2022-08-21T10:10:44.201Z","dependency_job_id":null,"html_url":"https://github.com/InitPHP/Events","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/InitPHP/Events","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FEvents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FEvents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FEvents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FEvents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InitPHP","download_url":"https://codeload.github.com/InitPHP/Events/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FEvents/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279183499,"owners_count":26121412,"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-10-16T02:00:06.019Z","response_time":53,"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":["php","php-event","php-hook","php-hooks"],"created_at":"2024-11-26T14:15:10.887Z","updated_at":"2025-10-16T11:28:30.017Z","avatar_url":"https://github.com/InitPHP.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Events\n\nIt allows you to run functions from outside in different places within your software. It allows you to set up a similar structure known as a hook in the Wordpress ecosystem.\n\n[![Latest Stable Version](http://poser.pugx.org/initphp/events/v)](https://packagist.org/packages/initphp/events) [![Total Downloads](http://poser.pugx.org/initphp/events/downloads)](https://packagist.org/packages/initphp/events) [![Latest Unstable Version](http://poser.pugx.org/initphp/events/v/unstable)](https://packagist.org/packages/initphp/events) [![License](http://poser.pugx.org/initphp/events/license)](https://packagist.org/packages/initphp/events) [![PHP Version Require](http://poser.pugx.org/initphp/events/require/php)](https://packagist.org/packages/initphp/events)\n\n## Requirements\n\n- PHP 5.6 or higher\n- [InitPHP EventEmitter Library](https://github.com/InitPHP/EventEmitter)\n\n## Installation\n\n```\ncomposer require initphp/events\n```\n\n## Usage\n\nCall the `trigger()` method where the events will be added. Send event with `on()` method.\n\n```php\nrequire_once \"vendor/autoload.php\";\nuse \\InitPHP\\Events\\Events;\n\nEvents::on('helloTrigger', function(){\n    echo 'Hello World' . PHP_EOL;\n}, 100);\n\nEvents::on('helloTrigger', function(){\n    echo 'Hi, World' . PHP_EOL;\n}, 99);\n\nEvents::trigger('helloTrigger');\n```\n\n**Output :**\n\n```\nHi World\nHello World\n```\n\n### Use of Arguments\n\n```php\nrequire_once \"vendor/autoload.php\";\nuse \\InitPHP\\Events\\Events;\n\nEvents::on('helloTrigger', function($name, $myName){\n    echo 'Hello ' . $name . '. I am ' . $myName . '.' . PHP_EOL;\n}, 100);\n\nEvents::on('helloTrigger', function($name, $myName){\n    echo 'Hi ' . $name . '. I am ' . $myName . '.' . PHP_EOL;\n}, 99);\n\nEvents::trigger('helloTrigger', 'World', 'John');\n```\n\n**Output :**\n\n```\nHi World. I am John.\nHello World. I am John.\n```\n\n## Credits\n\n- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) \u003c\u003cinfo@muhammetsafak.com.tr\u003e\u003e\n\n## License\n\nCopyright \u0026copy; 2022 [MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finitphp%2Fevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fevents/lists"}