Skip to content

Commit

Permalink
Merge pull request #7489 from codeigniter4/hot-reload
Browse files Browse the repository at this point in the history
 feat: Hot Reloading
  • Loading branch information
kenjis authored Jun 26, 2023
2 parents 02bc22c + 3b67f49 commit 2c1ce59
Show file tree
Hide file tree
Showing 14 changed files with 801 additions and 353 deletions.
12 changes: 11 additions & 1 deletion admin/css/debug-toolbar/toolbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
overflow: hidden;
overflow-y: auto;
padding: 0 12px 0 12px;

// Give room for OS X scrollbar
white-space: nowrap;
z-index: 10000;
Expand Down Expand Up @@ -501,3 +501,13 @@
.debug-bar-noverflow {
overflow: hidden;
}

/* ENDLESS ROTATE */
.rotate {
animation: rotate 9s linear infinite;
}
@keyframes rotate {
to {
transform: rotate(360deg);
}
}
7 changes: 7 additions & 0 deletions app/Config/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use CodeIgniter\Events\Events;
use CodeIgniter\Exceptions\FrameworkException;
use CodeIgniter\HotReloader\HotReloader;

/*
* --------------------------------------------------------------------
Expand Down Expand Up @@ -44,5 +45,11 @@
if (CI_DEBUG && ! is_cli()) {
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
Services::toolbar()->respond();
// Hot Reload route - for framework use on the hot reloader.
if (ENVIRONMENT === 'development') {
Services::routes()->get('__hot-reload', static function () {
(new HotReloader())->run();
});
}
}
});
27 changes: 27 additions & 0 deletions app/Config/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,31 @@ class Toolbar extends BaseConfig
* `$maxQueries` defines the maximum amount of queries that will be stored.
*/
public int $maxQueries = 100;

/**
* --------------------------------------------------------------------------
* Watched Directories
* --------------------------------------------------------------------------
*
* Contains an array of directories that will be watched for changes and
* used to determine if the hot-reload feature should reload the page or not.
* We restrict the values to keep performance as high as possible.
*
* NOTE: The ROOTPATH will be prepended to all values.
*/
public array $watchedDirectories = [
'app',
];

/**
* --------------------------------------------------------------------------
* Watched File Extensions
* --------------------------------------------------------------------------
*
* Contains an array of file extensions that will be watched for changes and
* used to determine if the hot-reload feature should reload the page or not.
*/
public array $watchedExtensions = [
'php', 'css', 'js', 'html', 'svg', 'json', 'env',
];
}
11 changes: 11 additions & 0 deletions system/Debug/Toolbar/Views/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -796,3 +796,14 @@
.debug-bar-noverflow {
overflow: hidden;
}

/* ENDLESS ROTATE */
.rotate {
animation: rotate 9s linear infinite;
}

@keyframes rotate {
to {
transform: rotate(360deg);
}
}
Loading

0 comments on commit 2c1ce59

Please sign in to comment.