diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 33e9a3e6d90..0d10f163dc0 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -5,7 +5,7 @@ This release is the first since the official release of HydePHP 1.0.0. It contains a number of bug fixes and improvements, but no breaking changes as the project has reached general availability and adheres to the semantic versioning backwards compatibility promise. ### Added -- for new features. +- Added a RealtimeCompiler config option to disable rendered pages being stored to disk in https://github.com/hydephp/develop/pull/1334 ### Changed - Updated discovery exception message to include the causing exception message in https://github.com/hydephp/develop/pull/1305 diff --git a/config/hyde.php b/config/hyde.php index 37047628aa6..d744efa2e8e 100644 --- a/config/hyde.php +++ b/config/hyde.php @@ -406,6 +406,7 @@ 'port' => env('SERVER_PORT', 8080), 'host' => env('SERVER_HOST', 'localhost'), 'dashboard' => env('SERVER_DASHBOARD', true), + 'save_preview' => true, ], /* diff --git a/packages/framework/config/hyde.php b/packages/framework/config/hyde.php index 37047628aa6..d744efa2e8e 100644 --- a/packages/framework/config/hyde.php +++ b/packages/framework/config/hyde.php @@ -406,6 +406,7 @@ 'port' => env('SERVER_PORT', 8080), 'host' => env('SERVER_HOST', 'localhost'), 'dashboard' => env('SERVER_DASHBOARD', true), + 'save_preview' => true, ], /* diff --git a/packages/realtime-compiler/src/Http/DashboardController.php b/packages/realtime-compiler/src/Http/DashboardController.php index 28587068c52..6d48fdad9ef 100644 --- a/packages/realtime-compiler/src/Http/DashboardController.php +++ b/packages/realtime-compiler/src/Http/DashboardController.php @@ -66,7 +66,13 @@ public static function enabled(): bool // This method is called from the PageRouter and allows us to serve a dynamic welcome page public static function renderIndexPage(HydePage $page): string { - $contents = file_get_contents(StaticPageBuilder::handle($page)); + if (config('hyde.server.save_preview')) { + $contents = file_get_contents(StaticPageBuilder::handle($page)); + } else { + Hyde::shareViewData($page); + + $contents = $page->compile(); + } // If the page is the default welcome page we inject dashboard components if (str_contains($contents, 'This is the default homepage')) { diff --git a/packages/realtime-compiler/src/Routing/PageRouter.php b/packages/realtime-compiler/src/Routing/PageRouter.php index 02d1c0fc014..55cc5dbc5d0 100644 --- a/packages/realtime-compiler/src/Routing/PageRouter.php +++ b/packages/realtime-compiler/src/Routing/PageRouter.php @@ -12,6 +12,7 @@ use Hyde\RealtimeCompiler\Concerns\SendsErrorResponses; use Hyde\RealtimeCompiler\Http\DashboardController; use Hyde\RealtimeCompiler\Http\HtmlResponse; +use Hyde\Hyde; /** * Handle routing for a web page request. @@ -63,7 +64,13 @@ protected function getHtml(HydePage $page): string return DashboardController::renderIndexPage($page); } - return file_get_contents(StaticPageBuilder::handle($page)); + if (config('hyde.server.save_preview')) { + return file_get_contents(StaticPageBuilder::handle($page)); + } else { + Hyde::shareViewData($page); + + return $page->compile(); + } } public static function handle(Request $request): Response