{"id":20827685,"url":"https://github.com/peridot-php/peridot-watcher-plugin","last_synced_at":"2025-06-19T02:37:24.089Z","repository":{"id":22804865,"uuid":"26151466","full_name":"peridot-php/peridot-watcher-plugin","owner":"peridot-php","description":"Watch tests for changes and re-run them","archived":false,"fork":false,"pushed_at":"2017-08-16T22:07:38.000Z","size":127,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-09T01:56:24.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://peridot-php.github.io/","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/peridot-php.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":"2014-11-04T03:41:11.000Z","updated_at":"2017-10-29T20:48:18.000Z","dependencies_parsed_at":"2022-08-21T12:31:20.227Z","dependency_job_id":null,"html_url":"https://github.com/peridot-php/peridot-watcher-plugin","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/peridot-php/peridot-watcher-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peridot-php%2Fperidot-watcher-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peridot-php%2Fperidot-watcher-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peridot-php%2Fperidot-watcher-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peridot-php%2Fperidot-watcher-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peridot-php","download_url":"https://codeload.github.com/peridot-php/peridot-watcher-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peridot-php%2Fperidot-watcher-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260673693,"owners_count":23044990,"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":[],"created_at":"2024-11-17T23:12:45.433Z","updated_at":"2025-06-19T02:37:19.006Z","avatar_url":"https://github.com/peridot-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Peridot Watcher Plugin\n======================\n\n[![Build Status](https://travis-ci.org/peridot-php/peridot-watcher-plugin.png)](https://travis-ci.org/peridot-php/peridot-watcher-plugin) [![HHVM Status](http://hhvm.h4cc.de/badge/peridot-php/peridot-watcher-plugin.svg)](http://hhvm.h4cc.de/package/peridot-php/peridot-watcher-plugin)\n\nWatch for changes in your Peridot tests and re run them when a change occurs.\n\n![Peridot watcher](https://raw.github.com/peridot-php/peridot-watcher-plugin/master/watcher.gif \"Peridot watcher in action\")\n\n## Usage\n\nWe recommend installing this plugin to your project via composer:\n\n```\n$ composer require --dev peridot-php/peridot-watcher-plugin:~1.3\n```\n\nYou can register the plugin via your [peridot.php](http://peridot-php.github.io/#plugins) file.\n\n```php\n\u003c?php\nuse Evenement\\EventEmitterInterface;\nuse Peridot\\Plugin\\Watcher\\WatcherPlugin;\n\nreturn function(EventEmitterInterface $emitter) {\n    $watcher = new WatcherPlugin($emitter);\n};\n```\n\nRegistering the plugin will make a `--watch` option available to the Peridot application:\n\n```\nvendor/bin/peridot specs/ --watch\n```\n\n## File events\n\nBy default, the watcher plugin will look for a \"file changed\" event, but you can configure the plugin to listen for the following events:\n\n- WatcherInterface::CREATE_EVENT\n- WatcherInterface::MODIFY_EVENT\n- WatcherInterface::DELETE_EVENT\n- WatcherInterface::ALL_EVENT\n\n```php\n\u003c?php\nuse Evenement\\EventEmitterInterface;\nuse Peridot\\Plugin\\Watcher\\WatcherPlugin;\nuse Peridot\\Plugin\\Watcher\\WatcherInterface;\n\nreturn function(EventEmitterInterface $emitter) {\n    $watcher = new WatcherPlugin($emitter);\n    $watcher-\u003esetEvents([WatcherInterface::CREATE_EVENT, WatcherInterface::MODIFY_EVENT]);\n};\n```\n\n## Tracking additional paths\n\nBy default, the watcher plugin just monitors the test path. If you want to track additional paths, you can do so in your peridot.php file:\n\n```php\n\u003c?php\nuse Evenement\\EventEmitterInterface;\nuse Peridot\\Plugin\\Watcher\\WatcherPlugin;\n\nreturn function(EventEmitterInterface $emitter) {\n    $watcher = new WatcherPlugin($emitter);\n    $watcher-\u003etrack(__DIR__ . '/src');\n};\n```\n\n## File criteria\n\nThe watcher will look for changes in files ending in .php by default. If you want to track additional\nfile types, you can add criteria as regular expressions in your peridot.php file:\n\n```php\n\u003c?php\nuse Evenement\\EventEmitterInterface;\nuse Peridot\\Plugin\\Watcher\\WatcherPlugin;\n\nreturn function(EventEmitterInterface $emitter) {\n    $watcher = new WatcherPlugin($emitter);\n    $watcher-\u003etrack(__DIR__ . '/src');\n    $watcher-\u003eaddFileCriteria('/\\.js$/');\n};\n```\n\nUsing the above, you can re run your tests when the source file changes. Since the Peridot watcher re runs your tests\nin a sub-process, it will actually detect new changes in your source.\n\n## Example specs\n\nFeel free to play around with the example spec using the watch option:\n\n```\n$ vendor/bin/peridot -c example/peridot.php example/modifyme.spec.php --watch\n```\n\n## Running plugin tests\n\n```\n$ vendor/bin/peridot specs/\n```\n\n## Inotify support\n\nThe watcher plugin will leverage the [Inotify extension](http://php.net/manual/en/book.inotify.php) if it is available, otherwise it will use a recursive directory strategy to watch for changes.\n\n## Note on IDEs\n\nSome IDEs might choke on ANSI sequences being returned from the watcher process. PHPStorm does not render colors\nfrom sub process output, but most terminals will. If using the terminal from your IDE is a must, you may want to run your\ntests using the `--no-colors` option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperidot-php%2Fperidot-watcher-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperidot-php%2Fperidot-watcher-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperidot-php%2Fperidot-watcher-plugin/lists"}