LPHP Engine

Please consider donating
to support this project!

Readme (via GitHub)

LPHP-Engine v1.1.0

GitHub GitHub Release Date GitHub release (latest by date including pre-releases) GitHub last commit GitHub issues GitHub language count


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 -->
  <?php ...

Inside this block you can declare variables, set compiler-flags or set the layout.

Creating variables

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

Calling variables

To call a variable within the HTML/PHP section, use the following syntax:

  set PageTitle = "My Website | Home";


Set Compiler-Flags

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">

LPHP Preprocessor

How to set up the LPHP Preprocessor

Download the latest installer and run it. It will automatically install the LPHP-Console and the LPHP-UI App on your system.

Option A (Recommended):

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.


Option B:

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.


Option C:

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.



Creating a Layout-Page

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>
  <!-- ... -->

After these files get compiled, one resulting .php-file will be created with the following contents:

    <header> <!-- ... --> </header>
      <!-- Menu Placeholder -->
      <h1>Welcome to my Website</h1>
        <!-- ... -->
    <footer> <!-- ... --> </footer>

By enhancing this sample, you can create multiple layouts that can quickly be changed by simply modifying the "Layout"-section in the calling file.

Currently supported features


  • $$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 to true 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


Q: When trying to run the programm, Windows-Defender pops up and stops me from running the program.

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

By using this Website, you automatically accept that we use cookies.
How do we use Cookies?