{"id":19436681,"url":"https://github.com/cydrickn/php-watcher","last_synced_at":"2025-04-24T21:31:26.621Z","repository":{"id":57937210,"uuid":"529280064","full_name":"cydrickn/php-watcher","owner":"cydrickn","description":"A simple directory and file watcher that was made using PHP.","archived":false,"fork":false,"pushed_at":"2025-02-06T13:52:55.000Z","size":8,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T11:51:16.284Z","etag":null,"topics":["php","php-watcher","watcher"],"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/cydrickn.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-08-26T14:00:48.000Z","updated_at":"2025-02-06T13:51:57.000Z","dependencies_parsed_at":"2022-08-31T08:21:11.606Z","dependency_job_id":null,"html_url":"https://github.com/cydrickn/php-watcher","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cydrickn%2Fphp-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cydrickn%2Fphp-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cydrickn%2Fphp-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cydrickn%2Fphp-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cydrickn","download_url":"https://codeload.github.com/cydrickn/php-watcher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250712949,"owners_count":21475107,"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":["php","php-watcher","watcher"],"created_at":"2024-11-10T15:12:18.843Z","updated_at":"2025-04-24T21:31:26.616Z","avatar_url":"https://github.com/cydrickn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Watcher\n\nA simple directory and file watcher that was made using PHP.\n\n## Requirements\n\n* PHP \u003e= 8.1\n\n## Installation\n\n```shell\ncomposer require cydrickn/php-watcher\n```\n\n## Usage\n\nTo use this package you just need to initialize the watcher and call the tick function\n\n```php\n\u003c?php\n\nrequire_once './vendor/autoload.php';\n\nuse \\Cydrickn\\PHPWatcher\\Adapters\\SwooleTimerAdapter;\n\n$watcher = new \\Cydrickn\\PHPWatcher\\Watcher(\n    new SwooleTimerAdapter(),\n    [__DIR__],\n    [__DIR__ . '/vendor/'],\n    function (array $changes) {\n        echo json_encode($changes) . PHP_EOL;\n    }\n);\n\n$watcher-\u003etick();\n```\n\n## Adapters\n\nCurrently, we have 3 premade adapters:\n\n### \\Cydrickn\\PHPWatcher\\Adapters\\SwooleTimerAdapter\n\nIf you are using Swoole/Openswoole then best choice to use this adapter\n\n### \\Cydrickn\\PHPWatcher\\Adapters\\NativeAdapter\n\nIf not using Swoole/Openswoole then you can go for this one, it uses PHP's do-while and sleep\n\n### \\Cydrickn\\PHPWatcher\\Adapters\\HybridAdapter\n\nThis is same as the version 1 where it will automatically use the SwooleTimerAdapter, if available or fallback to NativeAdapter.\nThis might be useful in a mixed environment.\n\n## Custom Adapter\n\nIf you don't want to use any pre-made adapter you can create your own adapter.\nExample:\n\n```php\n\u003c?php\n\nnamespace Your\\Namespace;\n\nuse Cydrickn\\PHPWatcher\\Adapters\\AdapterInterface;\n\nclass YourAdapter implements AdapterInterface\n{\n    public function tick(callable $handler, int $interval = 1000)\n    {\n        // Implement your own logic\n        // Also make sure to call the handler to trigger the checking of changed files\n        // e.g. call_user_func($handler);\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcydrickn%2Fphp-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcydrickn%2Fphp-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcydrickn%2Fphp-watcher/lists"}