@@ -99,10 +99,42 @@ If you're familiar with these tools, you can easily open the projects using the
9999php artisan native:open
100100```
101101
102+ ### Configuration
103+
104+ You can configure the folders that the ` watch ` command pays attention to in your ` config/nativephp.php ` file:
105+
106+ ``` php
107+ 'hot_reload' => [
108+ 'watch_paths' => [
109+ 'app',
110+ 'routes',
111+ 'config',
112+ 'database',
113+ // Make sure "public" is listed in your config [tl! highlight:1]
114+ 'public',
115+ ],
116+ ]
117+ ```
118+
119+ <aside >
120+
121+ #### Skip the prompts
122+
123+ If you are tired of prompts, you can run most commands - like ` native:run ` - with arguments and options that allow you
124+ to skip various prompts. Use the ` --help ` flag on a command to find out what values you can pass directly to it:
125+
126+ ``` shell
127+ php artisan native:run --help
128+ ```
129+
130+ </aside >
131+
132+
102133## Hot Reloading
103134
104135We've tried to make compiling your apps as fast as possible, but when coming from the 'make a change; hit refresh'-world
105- of PHP development that we all love, compiling apps can feel like a slow and time-consuming process.
136+ of typical browser-based PHP development that we all love, compiling apps can feel like a slow and time-consuming
137+ process.
106138
107139Hot reloading aims to make your app development experience feel just like home.
108140
@@ -112,69 +144,73 @@ You can start hot reloading by running the following command:
112144php artisan native:watch
113145```
114146
115- You can also pass the ` --watch ` option to the ` native:run ` command.
147+ <aside >
148+
149+ #### 🔥 Hot Tip!
150+
151+ You can also pass the ` --watch ` option to the ` native:run ` command. This will build and deploy a fresh version of your
152+ application to the target device and _ then_ start the watcher, all in one go.
153+
154+ </aside >
116155
117156This will start a long-lived process that watches your application's source files for changes, pushing them into the
118157emulator after any updates and reloading the current screen.
119158
120- Use this in tandem with Vite's own HMR for the platform you wish to test on:
159+ If you're using Vite, we'll also use your Node CLI tool of choice (` npm ` , ` bun ` , ` pnpm ` , or ` yarn ` ) to run Vite's HMR
160+ server.
121161
122- ``` shell
123- npm run dev -- --mode=ios
162+ ### Enabling HMR
124163
125- npm run dev -- --mode=android
126- ```
164+ To make HMR work, you'll need to add the ` hot ` file helper to your ` laravel ` plugin's config in your ` vite.config.js ` :
127165
128- This is useful during development for quickly testing changes without re-compiling your entire app. When you make
129- changes to any files in your Laravel app, the web view will be reloaded and your changes should show almost immediately.
166+ ``` js
167+ import { nativephpMobile , nativephpHotFile } from ' ./vendor/nativephp/mobile/resources/js/vite-plugin.js ' ; // [tl! focus]
130168
131- Vite HMR is perfect for apps that use SPA frameworks like Vue or React to build the UI. It even works on real devices,
132- not just simulators! As long as the device is on the same network as the development machine.
169+ export default defineConfig ({
170+ plugins: [
171+ laravel ({
172+ input: [' resources/css/app.css' , ' resources/js/app.js' ],
173+ refresh: true ,
174+ hotFile: nativephpHotFile (), // [tl! focus]
175+ }),
176+ tailwindcss (),
177+ nativephpMobile (),
178+ ]
179+ });
180+ ```
133181
134182<aside >
135183
136- #### Livewire and HMR on real devices
137-
138- Full hot reloading support for Livewire on real devices is not yet available.
139-
140- </aside >
184+ #### Two at a time, baby!
141185
142- ### Configuration
186+ If you're developing on macOS, you can run both Android and iOS watchers at the same time in separate terminals:
143187
144- You can configure the folders that the ` watch ` command pays attention to in your ` config/nativephp.php ` file:
188+ ``` shell
189+ # Terminal 1
190+ php artisan native:watch ios
145191
146- ``` php
147- 'hot_reload' => [
148- 'watch_paths' => [
149- 'app',
150- 'routes',
151- 'config',
152- 'database',
153- // Make sure "public" is listed in your config [tl! highlight:1]
154- 'public',
155- ],
156- ]
192+ # Terminal 2
193+ php artisan native:watch android
157194```
158195
159- ### Order matters
160-
161- Depending on which order you run these commands, you may find that hot reloading doesn't work immediately. It's often
162- best to get the commands running, get your app open, and then make a request to a new screen to allow your app to pick
163- up the ` hot ` file's presence and connect to the HMR server.
196+ This way you can see your changes reflected in real-time on both platforms ** at the same time** . Wild.
164197
198+ </aside >
165199
166- <aside >
200+ This is useful during development for quickly testing changes without re-compiling your entire app. When you make
201+ changes to any files in your Laravel app, the web view will be reloaded and your changes should show almost immediately.
167202
203+ Vite HMR is perfect for apps that use SPA frameworks like Vue or React to build the UI. It even works on real devices,
204+ not just simulators! As long as the device is on the same network as the development machine.
168205
206+ ** Don't forget to add ` public/ios-hot ` and ` public/android-hot ` to your ` .gitignore ` file!**
169207
170- #### Skip the prompts
208+ < aside >
171209
172- If you are tired of prompts, you can run most commands - like ` native:run ` - with arguments and options that allow you
173- to skip various prompts. Use the ` --help ` flag on a command to find out what values you can pass directly to it:
210+ #### Real iOS Devices Support
174211
175- ``` shell
176- php artisan native:run --help
177- ```
212+ Full hot reloading support works best on simulators. Full hot reloading support for non-JS changes on real iOS devices
213+ is not yet available.
178214
179215</aside >
180216
0 commit comments