jasonlewis/resource-watcher
Resource Watcher for Laravel monitors files and directories for changes and fires events when resources are modified, added, or deleted. Use it to trigger asset compilation, cache clearing, or custom development tasks automatically.
anything() and the new $resource, $absolutePath callback contract.use Illuminate\Support\Facades\Log;
// Register the listener for any change.
$listener->anything();
// Callback shape in v1.1.0:
// first parameter: the resource
// second parameter: the absolute path
function ($resource, string $absolutePath): void {
Log::info('Resource changed', [
'resource' => $resource,
'path' => $absolutePath,
]);
}
Use the package’s actual callback-registration method where applicable; the important part is that v1.1.0 adds anything() and standardises callbacks as resource-first, absolute-path-second.
anything() for audit-style listeners where you need to know that something changed, then branch on $resource inside the callback. For high-volume paths, prefer narrower listeners and reserve anything() for low-traffic directories or debugging.AppServiceProvider::boot() or a package-specific provider, and gate registration behind config or environment checks.$resource for domain logic and $absolutePath for logging, deduplication, and file-system operations. Avoid recomputing the path from the resource when the absolute path is already supplied.// Inside your listener callback:
ProcessResourceChange::dispatch($resource, $absolutePath);
anything() catches multiple change types, not just the one you normally use.$callback = function ($resource, string $absolutePath) use ($oldHandler) {
$oldHandler($absolutePath, $resource);
};
Only use an adapter if your old handler expected a different signature; otherwise migrate directly to the v1.1.0 signature.
$resource first and $absolutePath second. A closure that previously expected a string path as the first argument may now receive a resource object and fail with a TypeError when invoked. Audit every listener callback after upgrading, even though the release is marked backwards compatible.anything() can be noisy. It listens for any change, so filter early by resource type or path prefix. Otherwise you may process lock files, temp files, or unrelated writes.php artisan config:cache can hide new config keys. Run php artisan config:clear locally and redeploy cached config in production.$resource value must be serializable. If it is not, pass a stable identifier or path and resolve the resource inside the job.$resource and $absolutePath together at debug level. When a callback does not fire, verify listener registration first, then the path/filter, then the callback signature.How can I help you explore Laravel packages today?