- What is jasonlewis/resource-watcher used for in Laravel?
- Resource Watcher for Laravel watches local files and directories and fires events when resources are modified, added, or deleted. Typical uses include triggering asset compilation, clearing caches, warming caches, and running custom development tasks. It is an additive utility package rather than a platform component.
- How do I install jasonlewis/resource-watcher with Composer?
- Install it with composer require jasonlewis/resource-watcher. The expected onboarding is a single Composer require, optional config publishing, and listener registration in a service provider. Check the README for the exact config publish command and any package-specific setup.
- How do I register resource watcher listeners in Laravel?
- Register resource watcher listeners in a Laravel service provider using the package's fluent listener API. The v1.1.0 release emphasizes configuration-as-code registration, which keeps setup discoverable alongside other provider bindings. Confirm the exact listener methods in the README before wiring production code.
- What does the anything() wildcard listener do?
- The anything() wildcard listener is the most reusable capability highlighted in v1.1.0. It lets you collapse multiple per-event registrations into one handler, which is useful for audit logging, cache invalidation, and asset pipeline triggers. The assessment does not confirm whether it covers create, update, delete, and rename uniformly, so verify that in tests.
- What callback signature does Resource Watcher v1.1.0 use?
- The v1.1.0 callback contract is function ($resource, string $absolutePath). The first argument is a resource object, and the second is the absolute path. This is ergonomic because handlers do not need to re-derive paths, but it changes the previous argument order.
- Does upgrading to v1.1.0 break existing listeners?
- The release notes say the upgrade should not break backwards compatibility, but the callback argument order changed. A callback that types the first parameter as a string may now receive a resource object and raise a TypeError. Untyped closures can survive silently, making the breakage intermittent, so gate adoption on a dependency-level test run.
- Which Laravel and PHP versions are supported, and is the package maintained?
- The provided assessment does not list supported PHP or Laravel versions because Composer metadata was not fully reviewed, and it does not establish current maintenance activity. Check composer.json, the README, and the GitHub repository for version constraints, recent releases, and issue activity. Treat version support and maintenance status as unverified before adoption.
- Can Resource Watcher run in Docker, WSL, or on network mounts?
- Filesystem watchers are environment-sensitive, especially in Docker volumes, WSL, macOS FSEvents, network mounts, and systems with inotify limits. The assessment flags these risks but does not confirm the underlying watch mechanism or its fallback behavior. Test the package in your target container or mount setup before relying on it.
- How should I test filesystem watcher events in Laravel?
- Exercise every listener registration in your test suite and classify callbacks as untyped, single-param-typed, or two-param. This is especially important because the v1.1.0 callback signature can expose latent type errors. Use filesystem fixtures and avoid assuming event ordering or timing.
- Is Resource Watcher suitable for production or are there alternatives?
- It fits Laravel applications that need reactive behavior on local files, such as asset rebuilds, cache warming, and import-folder ingestion. It is a poor fit for distributed or ephemeral compute like multi-replica containers and serverless, where local filesystem state is not authoritative. In those environments use object-storage events or scheduled jobs; alternatives depend on your watch mechanism and deployment model.