crodas/watch-files
A lightweight PHP file watcher that monitors files and directories for changes, firing callbacks when they are created, modified, or deleted. Useful for auto-rebuilding assets, clearing caches, or rerunning tests during development without relying on external tools.
config:cache / view:cache / route:cache lifecycle and to any custom compiled-artifact directory.Schedule::call) short-circuit when a watched directory is unchanged, cutting wasted queue/CPU on a low-traffic app.Consider it when all of the following hold:
Look elsewhere when:
inotify/fswatch, spatie/file-watcher, Chokidar via Node, or a proper supervisor-managed daemon.Recommended posture: spike it, don't adopt it. Wrap it behind a narrow internal interface (ChangeDetector) so you can substitute a Finder-based implementation or a real watcher later without touching call sites. Budget a day to read the source and confirm its comparison algorithm (mtime vs. content hash) and its handling of deleted files.
For executives: This is a small, low-risk utility that lets us skip work when nothing has changed — no rebuilds, no cache warming, no redundant scheduled jobs. The upside is real but modest: reduced compute and faster deploys on unchanged code. The caveat is that it is an unmaintained, single-author library with essentially no adoption (9 stars, zero dependents), so I am not proposing it as a production dependency. I am proposing we spend roughly one engineer-day evaluating its approach and, if it fits, implement the same stateless snapshot check ourselves in about 100 lines behind an internal interface. The strategic value is the pattern — cheap change detection without infrastructure — not the package.
For engineering: The pitch is a stateless hasChanged(path, snapshot) primitive. No daemon, no supervisor, no inotify extension requirement — it works inside a normal PHP-FPM request or a cron tick. That makes it viable in environments where we cannot run a long-lived watcher, which is most of our estate. Concrete first applications: gating view:cache/config:cache rebuilds, short-circuiting the asset compile step in CI, and guarding a nightly scheduled job. Risks are equally concrete: it is effectively unmaintained, so we fork or reimplement rather than depend; it is snapshot-based, so it is unsuitable for hot-reload UX; and full-tree hashing must be scoped to a small set of paths or it will appear in our latency budget. Recommendation: prototype behind a ChangeDetector interface, measure the hashing cost on our largest watched directory, and only then decide between adopting, forking, or replacing with a Symfony Finder-based equivalent.
How can I help you explore Laravel packages today?