https://github.com/tobihatti/lphp-engine
✔🌍 Minimalistic Layout-Engine for PHP (similar to ASP.Net Razor)
https://github.com/tobihatti/lphp-engine
layout-engine lphp php php-extension preprocessor
Last synced: about 2 months ago
JSON representation
✔🌍 Minimalistic Layout-Engine for PHP (similar to ASP.Net Razor)
- Host: GitHub
- URL: https://github.com/tobihatti/lphp-engine
- Owner: TobiHatti
- License: gpl-3.0
- Created: 2020-05-23T15:56:21.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-08T22:20:49.000Z (over 4 years ago)
- Last Synced: 2025-02-15T05:24:54.873Z (4 months ago)
- Topics: layout-engine, lphp, php, php-extension, preprocessor
- Language: C#
- Homepage: https://endev.at/p/LPHP
- Size: 96.9 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LPHP-Engine v1.1.0

[](https://github.com/TobiHatti/LPHP-Engine/releases)
[](https://github.com/TobiHatti/LPHP-Engine/releases)
[](https://github.com/TobiHatti/LPHP-Engine/commits/master)
[](https://github.com/TobiHatti/LPHP-Engine/issues)
[](https://github.com/TobiHatti/LPHP-Engine)
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.## Features
- 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## Syntax
### LPHP-Instruction-Block
LPHP-Instructions must be placed inside a LPHP-Instruction-Block at the very beginning of the lphp-file:
```php
$${
// LPHP-Instruction-Block
}
$$PageTitle
```### Set Compiler-Flags
To view all possible compiler-flags, click [here](https://github.com/TobiHatti/LPHP-Engine/tree/master#compiler-flags).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.
```php
$${
NoCompile = true; // Set the NoCompile-Flag to true > No PHP-file gets created from this file.
}
```### Functions
Functions can be called within the HTML/PHP-section of the file.For a list of all possible functions, click [here](https://github.com/TobiHatti/LPHP-Engine/tree/master#functions-1)
```php
$$RenderPage("Path/To/File/To/Be/Inserted")
```## 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.
## Usage
### 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.:
```php
$${
// Filename: sampleLayout.lphp
NoCompile = true;
}
$$PageTitle
$$RenderPage("templates/menuTemplate.php")
$$RenderBody()
```
- Step 2: Create a content-page (.lphp) that calls the layout:
```php
$${
// Filename: index.lphp
Layout = "sampleLayout.lphp";
set PageTitle = "Home";
}Welcome to my Website
```
After these files get compiled, one resulting .php-file will be created with the following contents:
```html
Home
Welcome to my Website
```
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
### Functions
- `$$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.### Compiler-Flags
- `NoCompile` (default: `false`):
Determines, if a LPHP file should be converted and saved as a PHP-file. Usually set to `true` in layout-pages.### Preprocessor-Options
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`__
## FAQ### 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.## Downloads
Get the current version [here](https://github.com/TobiHatti/LPHP-Engine/releases/latest)
Version: 1.1.0
MD5: E9151E940F663AB4F97FD57DA4AB9DB9