Skip to content

Commit 98239ad

Browse files
authored
Merge pull request #7862 from kenjis/fix-docs-missing-config-update
docs: add missing Config updates for Hot Reloading
2 parents 1f09614 + c34ae21 commit 98239ad

1 file changed

Lines changed: 72 additions & 2 deletions

File tree

user_guide_src/source/installation/upgrade_440.rst

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ Config Files
155155
app/Config/App.php
156156
------------------
157157

158-
- The property ``$proxyIPs`` must be an array. If you don't use proxy servers,
159-
it must be ``public array $proxyIPs = [];``.
158+
The property ``$proxyIPs`` must be an array. If you don't use proxy servers,
159+
it must be ``public array $proxyIPs = [];``.
160160

161161
.. _upgrade-440-config-routing:
162162

@@ -176,6 +176,76 @@ So you need to do:
176176
2. Remove all settings in **app/Config/Routes.php** that are no longer needed.
177177
3. If you use the environment-specific routes files, add them to the ``$routeFiles`` property in **app/Config/Routing.php**.
178178

179+
app/Config/Toolbar.php
180+
----------------------
181+
182+
You need to add the new properties ``$watchedDirectories`` and ``$watchedExtensions``
183+
for :ref:`debug-toolbar-hot-reload`::
184+
185+
--- a/app/Config/Toolbar.php
186+
+++ b/app/Config/Toolbar.php
187+
@@ -88,4 +88,31 @@ class Toolbar extends BaseConfig
188+
* `$maxQueries` defines the maximum amount of queries that will be stored.
189+
*/
190+
public int $maxQueries = 100;
191+
+
192+
+ /**
193+
+ * --------------------------------------------------------------------------
194+
+ * Watched Directories
195+
+ * --------------------------------------------------------------------------
196+
+ *
197+
+ * Contains an array of directories that will be watched for changes and
198+
+ * used to determine if the hot-reload feature should reload the page or not.
199+
+ * We restrict the values to keep performance as high as possible.
200+
+ *
201+
+ * NOTE: The ROOTPATH will be prepended to all values.
202+
+ */
203+
+ public array $watchedDirectories = [
204+
+ 'app',
205+
+ ];
206+
+
207+
+ /**
208+
+ * --------------------------------------------------------------------------
209+
+ * Watched File Extensions
210+
+ * --------------------------------------------------------------------------
211+
+ *
212+
+ * Contains an array of file extensions that will be watched for changes and
213+
+ * used to determine if the hot-reload feature should reload the page or not.
214+
+ */
215+
+ public array $watchedExtensions = [
216+
+ 'php', 'css', 'js', 'html', 'svg', 'json', 'env',
217+
+ ];
218+
}
219+
220+
221+
app/Config/Events.php
222+
---------------------
223+
224+
You need to add the code to add a route for :ref:`debug-toolbar-hot-reload`::
225+
226+
--- a/app/Config/Events.php
227+
+++ b/app/Config/Events.php
228+
@@ -4,6 +4,7 @@ namespace Config;
229+
230+
use CodeIgniter\Events\Events;
231+
use CodeIgniter\Exceptions\FrameworkException;
232+
+use CodeIgniter\HotReloader\HotReloader;
233+
234+
/*
235+
* --------------------------------------------------------------------
236+
@@ -44,5 +45,11 @@ Events::on('pre_system', static function () {
237+
if (CI_DEBUG && ! is_cli()) {
238+
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
239+
Services::toolbar()->respond();
240+
+ // Hot Reload route - for framework use on the hot reloader.
241+
+ if (ENVIRONMENT === 'development') {
242+
+ Services::routes()->get('__hot-reload', static function () {
243+
+ (new HotReloader())->run();
244+
+ });
245+
+ }
246+
}
247+
});
248+
179249
app/Config/Cookie.php
180250
---------------------
181251

0 commit comments

Comments
 (0)