-
Notifications
You must be signed in to change notification settings - Fork 0
endCode
Finalizes the output buffer, transforms all internal .php links into nested static .html relative paths, ensures target directories exist, writes the resulting static HTML file if content changes are detected, and optionally delegates local asset extraction/copying.
📌 This method captures the rendered output since the
startCode()method was executed.
endCode(): bool
- Takes no arguments.
📌 This method automatically derives the target filename from the
$this->fileproperty which is automatically set with the current PHP file when class is instantiated.It maps the current script and
$_GETstate to a relative destination path (e.g.,blog.php?year=2026&month=07->blog/2026/07.html) and measures directory depth. Then it transforms links and rewrites allhrefandactionattributes, automatically prepending relative directory traversals (../) based on depth.If
$this->outputPathis specified, differs from$this->path, and thecopyAssetsconfig variable is set to true,endCode()automatically invokesprocessLocalAssets()to clone local CSS and image dependencies into the target build output directory before closing the output buffer.
(bool)
: Returns true if a static HTML file was newly generated or updated on disk, or false if the content remained unchanged (skipped file write) or if writing failed.
$file->startCode();
// PHP and HTML code goes here...
$file->endCode();
| Config Key | Default Value | Allowed Values | Description |
|---|---|---|---|
| copyAssets | true | bool | Copy local assets when using endCode(). |
Determines whether local assets (such as images, stylesheets, and local linked resources) embedded in the generated HTML should be scanned and copied into the target output directory when generating static files.
Trigger Conditions: Local asset copying executes during endCode() only if all of the following conditions are met:
-
An output directory (
$this->outputPath) is defined (setOutputPath()) and non-empty. -
The target output path differs from the source path (
$this->path). -
The
copyAssetsconfiguration value evaluates strictly totrue.
- No debug errors.
buildStaticPath | processLocalAssets | startCode | writeHtml