Download the PHP package larsgmortensen/liteview without Composer

On this page you can find all versions of the php package larsgmortensen/liteview. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package liteview

LiteView - A Lightweight & High-Performance PHP Template Engine

LiteView is a fast, minimal, efficient, single-file PHP template engine focused on runtime performance and developer ergonomics. It offers a very low overhead and an intuitive syntax inspired by other modern template engines while staying dependency-free and easy to embed in any codebase (PHP 8.1+).


πŸš€ Features that make LiteView stand out


πŸ“¦ Installation

Via Composer (recommended):

`

Or manually add the class file (e.g. src/LiteView/LiteView.php) and load it via Composer’s autoloader or a require_once:

Tip: Place your cache directory outside webroot (or deny direct access).


πŸš€ Quick Start

Capture output as a string:

Layout (layout.html)

Page template (index.html)


πŸ”€ Template Syntax

Feature Syntax Notes
Escaped output {{ expr }} Encoded with htmlspecialchars(..., ENT_QUOTES \| ENT_SUBSTITUTE, 'UTF-8').
Raw output {{{ expr }}} No escaping. Only for trusted HTML.
Raw PHP echo {?= expr ?} Emits the evaluated expression directly.
Raw PHP block {? /* php */ ?} Executes only if allowPhpTags=true.
If / Elseif / Else / Endif {% if (...) %}...{% elseif (...) %}{% else %}{% endif %} Pure PHP conditions.
Foreach / Endforeach {% foreach ($items as $i) %}...{% endforeach %} Pure PHP foreach.
Extends {% extends "layout.html" %} One parent per template.
Block / Endblock {% block name %}...{% endblock %} Defines content for a named yield.
Yield {% yield name %} Replaced with the child’s matching block.
Include {% include "file.html" %} Recurses with depth guard (16).
Template comments {# ... #} Nested comments supported. Removed before parsing.

Quotes: Always use double quotes in {% extends %} and {% include %}.


πŸ“– User Guide

LiteView is designed to be simple, fast, and intuitive. Below you’ll find examples of all supported features so you can get productive immediately.


πŸ”’ Secure Output

Escape variables safely with {{ ... }}:

This prevents XSS by applying htmlspecialchars().

For raw output (no escaping), use triple braces:

⚠ Only use raw output with trusted content.


πŸ“‚ Template Inheritance

Define reusable layouts with {% extends %}, {% block %}, and {% yield %}.

layout.html

index.html

LiteView enforces strict fail-fast validation:


πŸ“¦ Includes

Insert reusable snippets with {% include "..." %}:

Includes are recursive and protected against infinite loops with a depth guard.


❌ Comments

Comment out code with {# ... #}:

Supports nested comments safely.


➑️ Nested comments

LiteView supports nested {# ... #} comments, something most template engines do not.

This means you can safely comment out larger blocks of code without worrying about inner {# ... #} markers breaking the parser:

The entire block is removed cleanly, leaving no stray #} in the output.


πŸ”€ Conditionals

Use native PHP expressions:


πŸ” Loops

Iterate with foreach:


βœ‚ Whitespace Trimming

If enabled, LiteView removes redundant whitespace outside <pre>, <code>, <textarea>, <script>, and <style>:

➑ becomes:


πŸ—‘ HTML Comment Removal

If enabled, HTML comments are removed (except conditional IE comments):

➑ becomes:


🐘 Embedding PHP

Raw PHP blocks are allowed (configurable via $allowPhpTags):

If disabled, these tags are ignored.


πŸ”₯ Clearing the Cache

Force templates to recompile by clearing the cache:

Deletes all compiled .php templates in the cache directory.


🧰 API

Parameters


πŸ’‘ Why LiteView?

LiteView exists for developers who want performance and simplicity without the overhead of large engines like Twig or Smarty.

✨ Blazing Fast – Compiles to lean PHP with minimal overhead.

✨ Fail-Fast Safety – Strict inheritance validation prevents silent template bugs.

✨ Zero Dependencies – Pure PHP, fully static API, no instantiation.

✨ Full PHP Power – Use real PHP expressions in conditionals and loops.

✨ Lightweight by Design – Single-file engine, ideal for micro-frameworks and high-traffic apps.

✨ Flexible & Configurable – Toggle whitespace trimming, HTML comment removal, and raw PHP execution.

LiteView is the perfect balance of developer productivity and runtime performance. πŸš€


🧬 Strict Inheritance (Fail-Fast)

LiteView resolves blocks at compile time and enforces invariants:

This catches layout mistakes early and keeps runtime hot paths minimal (no runtime block stack).


πŸ—œοΈ Caching & Invalidation

Deploy note: If your deployment preserves file mtimes (cp -p, rsync --times), changes might not trigger recompilation. Ensure mtimes update or call LiteView::clearCache() post-deploy.


πŸ” Security Notes


πŸ§ͺ Troubleshooting


πŸ“ˆ Performance Tips


πŸ“¦ Packagist

LiteView on Packagist: πŸ‘‰ https://packagist.org/packages/larsgmortensen/liteview


πŸ“œ License

LiteView is released under the GNU General Public License v3.0. See LICENSE for details.

🀝 Contributing

Contributions are welcome! Feel free to fork this repository, submit issues, or open a pull request.

✍️ Author

Developed by Lars Grove Mortensen Β© 2025. Feel free to reach out or contribute!


LiteView – the single-file engine that gives you speed, safety, and simplicity πŸš€


🌟 If you find this library useful, give it a star on GitHub! 🌟


All versions of liteview with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package larsgmortensen/liteview contains the following files

Loading the files please wait ...