{"id":19956101,"url":"https://github.com/krowinski/php-inotify","last_synced_at":"2025-05-03T19:32:40.553Z","repository":{"id":35058735,"uuid":"201744250","full_name":"krowinski/php-inotify","owner":"krowinski","description":"Monitor files and folders in real time using inotify. Wraps php inotify module into object and dispatch them using event dispatcher.","archived":false,"fork":false,"pushed_at":"2022-12-20T19:29:38.000Z","size":24,"stargazers_count":19,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-04T04:46:58.089Z","etag":null,"topics":["dispatch","filesystem","inotify","php","php-inotify"],"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/krowinski.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":"2019-08-11T09:29:52.000Z","updated_at":"2025-01-28T18:51:06.000Z","dependencies_parsed_at":"2023-01-15T12:56:24.162Z","dependency_job_id":null,"html_url":"https://github.com/krowinski/php-inotify","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krowinski%2Fphp-inotify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krowinski%2Fphp-inotify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krowinski%2Fphp-inotify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krowinski%2Fphp-inotify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krowinski","download_url":"https://codeload.github.com/krowinski/php-inotify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252242222,"owners_count":21717124,"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":["dispatch","filesystem","inotify","php","php-inotify"],"created_at":"2024-11-13T01:30:03.126Z","updated_at":"2025-05-03T19:32:40.296Z","avatar_url":"https://github.com/krowinski.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"php-inotify\n=========\n[![Build Status](https://scrutinizer-ci.com/g/krowinski/php-inotify/badges/build.png?b=master)](https://scrutinizer-ci.com/g/krowinski/php-inotify/build-status/master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/krowinski/php-inotify/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/krowinski/php-inotify/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/krowinski/php-inotify/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/krowinski/php-inotify/?branch=master)\n[![PHP Tests](https://github.com/krowinski/php-inotify/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/krowinski/php-inotify/actions/workflows/tests.yml)\n\nWhy\n=========\nIn cases when you need to scan dir to find new files or files modifications, \nyou probably will create some script and implements pulling mechanism.\nThat is good for small systems with less files but not efficient enough for big one.  \nAnd that why we got inotify mechanism that generate event on file|dir changes \nlike create, delete, change and many more that we can listen to.\nMore info in php manual. [here](https://www.php.net/manual/en/book.inotify.php) \n\nInstallation\n=========\n```bash\ncomposer require krowinski/php-inotify\n```\n\nInstalling inotify extension for php \n=========\nTo listen on event we need php extension called inotify.\nIn most cases you just need to install using pecl\n(example in [dockerfile](https://github.com/krowinski/php-inotify/blob/master/Dockerfile))\n\n\nExample\n=========\nYou can find example in \n[example.php](https://github.com/krowinski/php-inotify/blob/master/example/example.php)\nand events that you can listen to [InotifyEventCodeEnum.php](https://github.com/krowinski/php-inotify/blob/master/src/Inotify/InotifyEventCodeEnum.php)\nEvent implement Arrayable, JsonSerializable and __toString.\n \n```php\nArray\n(\n    [id] =\u003e 1\n    [eventCode] =\u003e 256\n    [eventDescription] =\u003e ON_CREATE - File or directory created in watched directory\n    [uniqueId] =\u003e 0\n    [fileName] =\u003e 2\n    [pathName] =\u003e /tmp\n    [customName] =\u003e test\n    [pathWithFile] =\u003e /tmp/2\n    [timestamp] =\u003e 1565610455\n)\nArray\n(\n    [id] =\u003e 1\n    [eventCode] =\u003e 32\n    [eventDescription] =\u003e ON_OPEN - File was opened\n    [uniqueId] =\u003e 0\n    [fileName] =\u003e 2\n    [pathName] =\u003e /tmp\n    [customName] =\u003e test\n    [pathWithFile] =\u003e /tmp/2\n    [timestamp] =\u003e 1565610455\n)\nArray\n(\n    [id] =\u003e 1\n    [eventCode] =\u003e 4\n    [eventDescription] =\u003e ON_ATTRIB - Metadata changed (e.g. permissions, mtime, etc.)\n    [uniqueId] =\u003e 0\n    [fileName] =\u003e 2\n    [pathName] =\u003e /tmp\n    [customName] =\u003e test\n    [pathWithFile] =\u003e /tmp/2\n    [timestamp] =\u003e 1565610455\n)\nArray\n(\n    [id] =\u003e 1\n    [eventCode] =\u003e 8\n    [eventDescription] =\u003e ON_CLOSE_WRITE - File opened for writing was closed\n    [uniqueId] =\u003e 0\n    [fileName] =\u003e 2\n    [pathName] =\u003e /tmp\n    [customName] =\u003e test\n    [pathWithFile] =\u003e /tmp/2\n    [timestamp] =\u003e 1565610455\n)\nArray\n(\n    [id] =\u003e 1\n    [eventCode] =\u003e 512\n    [eventDescription] =\u003e ON_DELETE - File or directory deleted in watched directory\n    [uniqueId] =\u003e 0\n    [fileName] =\u003e 2\n    [pathName] =\u003e /tmp\n    [customName] =\u003e test\n    [pathWithFile] =\u003e /tmp/2\n    [timestamp] =\u003e 1565610456\n)\n```\n\nWhere:\n```\n[id] =\u003e watch descriptor\n[eventCode] =\u003e bit mask of events\n[eventDescription] =\u003e human readable event description (can be UNKNOWN if not found in InotifyEventCodeEnum)\n[uniqueId] =\u003e is a unique id to connect related events (e.g. IN_MOVE_FROM and IN_MOVE_TO)\n[fileName] =\u003e name of a file (e.g. if a file was modified in a watched directory)\n[pathName] =\u003e watched resource you give in configuration\n[customName] =\u003e custom resource name for external parsing like \"form-upload-dir\" etc\n[pathWithFile] =\u003e helper that contact pathName and fileName\n[timestamp] =\u003e ...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrowinski%2Fphp-inotify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrowinski%2Fphp-inotify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrowinski%2Fphp-inotify/lists"}