The LPHP-Engine (Layout-Based PHP-Engine) provides a minimalistic Layout-Engine for PHP. Based on the Layout-features of the ASP.NET Razor framework. This allows you to create PHP-Based Websites with layouts, similar to Razor, without the need of a webserver that supports ASP.Net Websites.
- Layout features similar to ASP.Net Razor in PHP
- Defining and calling local and global variables
- Defining page layouts with just a few lines of code
- Automatic conversion from .lphp files to php-files with debug-information
LPHP-Instructions must be placed inside a LPHP-Instruction-Block at the very beginning of the lphp-file:
$${
// LPHP-Instruction-Block
}
<!-- Everything after the LPHP-Instruction-Block will be interpreted as default HTML+PHP -->
<html>
<head>
<?php ...
Inside this block you can declare variables, set compiler-flags or set the layout.
Types of variables:
- Local variables: can be accessed by the declaring file, as well as all files that get called or have been called from this file
- Global variables: can be accessed by any file in the project-folder
$${
set MyVariable1 = "SampleText"; // Create local variable "MyVariable1" with string
set MyVariable2 = 12345; // Create local variable "MyVariable2" with decimal
set MyVariable3 = true; // Create local variable "MyVariable2" with boolean
glob GlobalVariable1 = "SampleText"; // Create global variable "GlobalVariable1" with string
glob GlobalVariable2 = 12345; // Create global variable "GlobalVariable2" with decimal
glob GlobalVariable3 = true; // Create global variable "GlobalVariable2" with boolean
}
To call a variable within the HTML/PHP section, use the following syntax:
$${
set PageTitle = "My Website | Home";
}
<html>
<head>
<title>$$PageTitle</title>
</head>
To view all possible compiler-flags, click here.
Compiler-flags can be used to manipulate and modify the output and the resulting PHP-file.
Compiler-flags must be set in the LPHP-instruction-block at the beginning of the page.
$${
NoCompile = true; // Set the NoCompile-Flag to true > No PHP-file gets created from this file.
}
Functions can be called within the HTML/PHP-section of the file.
For a list of all possible functions, click here
<div class="pageContents">
$$RenderPage("Path/To/File/To/Be/Inserted")
</div>
Download the latest installer and run it. It will automatically install the LPHP-Console and the LPHP-UI App on your system.
Call the LPHP UI App, select your project directory, check the options you want to enable and start the engine. The app automatically saves your settings for the next session.
Call the LPHP-Console without any parameters. Upon startup, the console will prompt you to enter the Path of your LPHP project. After entering the path, the LPHP-Watchdog will constantly monitor the entered directory, until the console is closed.
Call the LPHP-Console with the target directory as a parameter:
The LPHP-console can accept 1 parameter: The path to the directory, where the LPHP-Files are located. (Usually the website's root-folder)
Program-Call (Example):
"C:\Path\To\LPHP\Executable\LPHP_Preprocessor.exe" "H:\Projects\MyPersonalWebsite"
If everything was set up correctly, the preprocessor will constantly watch for changes in the directory and compile any lphp-files where a change gets detected.
To fully utilise the layout-features, the following template can be used:
- Step 1: Create a Layout-File (.lphp): In this file, the basic layout of the page is defined, such as header, footer, menu, etc.:
$${
// Filename: sampleLayout.lphp
NoCompile = true;
}
<html>
<head>
<title>$$PageTitle</title>
<head>
<body>
<header> <!-- ... --> </header>
<nav>
$$RenderPage("templates/menuTemplate.php")
</nav>
<main>
$$RenderBody()
</main>
<footer> <!-- ... --> </footer>
</body>
</html>
- Step 2: Create a content-page (.lphp) that calls the layout:
$${
// Filename: index.lphp
Layout = "sampleLayout.lphp";
set PageTitle = "Home";
}
<h1>Welcome to my Website</h1>
<article>
<!-- ... -->
</article>
After these files get compiled, one resulting .php-file will be created with the following contents:
<html>
<head>
<title>Home</title>
<head>
<body>
<header> <!-- ... --> </header>
<nav>
<!-- Menu Placeholder -->
</nav>
<main>
<h1>Welcome to my Website</h1>
<article>
<!-- ... -->
</article>
</main>
<footer> <!-- ... --> </footer>
</body>
</html>
By enhancing this sample, you can create multiple layouts that can quickly be changed by simply modifying the "Layout"-section in the calling file.
$$RenderBody()
: Only used within a layout-file. Pastes the content of the calling file in this section.$$RenderPage("Path/To/File")
: Pastes any files content in this section.
NoCompile
(default:false
): Determines, if a LPHP file should be converted and saved as a PHP-file. Usually set totrue
in layout-pages.
These options can be changed in the LPHP.ini-file (by default located under "C:\Users\YOUR_USER\AppData\Local\Endev\LPHP"), or by changing the settings in the LPHP-UI App.
REMOVE_HTML_COMMENTS
(default:True
): Determines, if HTML-comments should still be included in the.php
output.MIN_OUTPUT_ENABLED
(default:True
): Outputs the.php
-file without line-breaks, tabs or unneccecary white-spaces.XML_OUTPUT_ENABLED
(default:False
) Outputs the .php-file with propper indents and line-breaks. (More resource-intensive, causes compile-time to be slower.)
Note: When only one output mode (MIN_OUTPUT_ENABLED
, XML_OUTPUT_ENABLED
) is set to True
, the file-extension will always be .php
. When both output-modes are selected, the XML-output has the file-extension .php
and the MIN-output .min.php
A: The reason for this is the new trust-system of windows-defender that came with windows 10, it blocks any programms that don't have enough "reputation", which a program gains reputation by getting downloaded by many individuals. Therefor a new program with no reputation gets marked as "Potentially harmfull." To install it anyway, click on "More Info" and then on "Run anyway". Alternatively, you can just download the source-code and compile the program yourself.
Get the current version here
Version: 1.1.0
MD5: E9151E940F663AB4F97FD57DA4AB9DB9