Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Agents
hotwired-laravel/hotreload
claude-code
cursor
sse
file-watcher
turbo
javascript-bundles
stimulus
inotify
dom-morphing

This file provides guidance to Coding Agents when working with code in this repository.

Install
php artisan boost:add-skill hotwired-laravel/hotreload

Save this content to: AGENTS.md

# AGENTS.md

This file provides guidance to Coding Agents when working with code in this repository.

## Project

Hotreload for Turbo Laravel (`hotwired-laravel/hotreload`) — a Laravel package that detects source code changes and updates the browser smoothly without manual reloads. Inspired by Hotwire Spark, reimplemented in PHP for Laravel. It uses Server-Sent Events (SSE) to stream file change notifications to the browser, where JavaScript reloaders apply updates.

## Commands

```bash
# Tests
vendor/bin/phpunit tests/Unit              # Unit tests
vendor/bin/phpunit tests/Browser           # Browser tests (Dusk, requires ChromeDriver)
vendor/bin/phpunit --filter=CssReloadTest  # Single test class

# JavaScript build
npm run build                              # Build JS bundles (UMD, ESM, minified) to dist/
npm run watch                              # Watch mode for JS development

# Workbench app (used for browser tests)
composer serve                             # Build, prepare, and serve the test app
composer build                             # Build the workbench app only
composer prepare                           # Run testbench discover
composer dusk:install-chromedriver         # Install/update ChromeDriver
```

## Architecture

### PHP (src/)

**Entry point:** `HotreloadServiceProvider` registers middleware, routes, and config.

**SSE flow:** `HotreloadMiddleware` injects the JS bundle into HTML responses. The client opens an SSE connection to `HotreloadServerSentEventsController`, which creates file watchers and streams change events (`ReloadHtml`, `ReloadCss`, `ReloadStimulus`).

**File watchers** implement the `Contracts\FileWatcher` interface (`boot()`, `tick()`, `stop()`):

- `InotifyFileWatcher` — uses the PHP inotify extension for efficient monitoring
- `SimpleFileWatcher` — fallback that polls file mtimes
- `FileWatchers` — composite that manages multiple watchers

**Configuration:** `Hotreload` class is the static facade for configuring watcher type and watched paths. Default paths: `resources/views`, `resources/css`, `public/dist/css`, `resources/js/controllers`. Enabled via `HOTRELOAD_ENABLED` env var.

### JavaScript (js/ → dist/)

**Reloaders** handle different change types:

- `MorphHtmlReloader` — uses Idiomorph for morphological DOM diffing (default)
- `ReplaceHtmlReloader` — full page reload via Turbo visit
- `CssReloader` — reloads stylesheet links with cache busting
- `StimulusReloader` — reimports changed Stimulus controllers

Config is read from `<meta>` tags (`hotwire-hotreload:html-reload-method`, `hotwire-hotreload:logging`).

Built with esbuild (`scripts/build.js`), outputs three bundles plus a manifest.json with version hash.

### Testing

- Unit tests (`tests/Unit/`) extend `UnitTestCase` (Orchestra Testbench)
- Browser tests (`tests/Browser/`) extend `BrowserTestCase` (Testbench Dusk) — these manipulate files in the workbench app and assert browser behavior
- Workbench app (`workbench/`) is the Laravel app used for testing
- CI runs PHP 8.3/8.4/8.5 × Laravel 12/13, with inotify extension installed

AGENTS.md

This file provides guidance to Coding Agents when working with code in this repository.

Project

Hotreload for Turbo Laravel (hotwired-laravel/hotreload) — a Laravel package that detects source code changes and updates the browser smoothly without manual reloads. Inspired by Hotwire Spark, reimplemented in PHP for Laravel. It uses Server-Sent Events (SSE) to stream file change notifications to the browser, where JavaScript reloaders apply updates.

Commands

# Tests
vendor/bin/phpunit tests/Unit              # Unit tests
vendor/bin/phpunit tests/Browser           # Browser tests (Dusk, requires ChromeDriver)
vendor/bin/phpunit --filter=CssReloadTest  # Single test class

# JavaScript build
npm run build                              # Build JS bundles (UMD, ESM, minified) to dist/
npm run watch                              # Watch mode for JS development

# Workbench app (used for browser tests)
composer serve                             # Build, prepare, and serve the test app
composer build                             # Build the workbench app only
composer prepare                           # Run testbench discover
composer dusk:install-chromedriver         # Install/update ChromeDriver

Architecture

PHP (src/)

Entry point: HotreloadServiceProvider registers middleware, routes, and config.

SSE flow: HotreloadMiddleware injects the JS bundle into HTML responses. The client opens an SSE connection to HotreloadServerSentEventsController, which creates file watchers and streams change events (ReloadHtml, ReloadCss, ReloadStimulus).

File watchers implement the Contracts\FileWatcher interface (boot(), tick(), stop()):

  • InotifyFileWatcher — uses the PHP inotify extension for efficient monitoring
  • SimpleFileWatcher — fallback that polls file mtimes
  • FileWatchers — composite that manages multiple watchers

Configuration: Hotreload class is the static facade for configuring watcher type and watched paths. Default paths: resources/views, resources/css, public/dist/css, resources/js/controllers. Enabled via HOTRELOAD_ENABLED env var.

JavaScript (js/ → dist/)

Reloaders handle different change types:

  • MorphHtmlReloader — uses Idiomorph for morphological DOM diffing (default)
  • ReplaceHtmlReloader — full page reload via Turbo visit
  • CssReloader — reloads stylesheet links with cache busting
  • StimulusReloader — reimports changed Stimulus controllers

Config is read from <meta> tags (hotwire-hotreload:html-reload-method, hotwire-hotreload:logging).

Built with esbuild (scripts/build.js), outputs three bundles plus a manifest.json with version hash.

Testing

  • Unit tests (tests/Unit/) extend UnitTestCase (Orchestra Testbench)
  • Browser tests (tests/Browser/) extend BrowserTestCase (Testbench Dusk) — these manipulate files in the workbench app and assert browser behavior
  • Workbench app (workbench/) is the Laravel app used for testing
  • CI runs PHP 8.3/8.4/8.5 × Laravel 12/13, with inotify extension installed
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log