Download the PHP package enlivenapp/vision without Composer

On this page you can find all versions of the php package enlivenapp/vision. 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 vision

Stable? Not Quite Yet License PHP Version Monthly Downloads Total Downloads GitHub Issues Contributors Latest Release Contributions Welcome

Vision

Lightweight, framework-agnostic PHP template engine with auto-escaping, template inheritance, includes, filters, and custom tags.

Requirements

No framework dependencies. Works with any PHP project.

Installation

Quick Start

Create the engine once, optionally register any custom tags or filters your app needs, then render .tpl files:

That's the full lifecycle. The rest of this document covers template syntax and the engine API in detail.

Template Syntax

Vision templates are plain .tpl files. Four delimited constructs are recognized — everything outside them is emitted verbatim.

Delimiter Purpose
{{ ... }} Output an expression, auto-escaped
{! ... !} Output an expression, raw (no escaping)
{% ... %} Control flow, blocks, includes, extends, and custom tags
{# ... #} Comments (stripped during lexing — never reach output)

Output

{{ ... }} is the default output form. Results are passed through htmlspecialchars() with ENT_QUOTES | ENT_SUBSTITUTE and UTF-8, so output is safe by default:

If any step in a dot-notation chain is missing, the whole expression resolves to null silently.

Use {! ... !} when you intentionally want unescaped output (e.g. pre-rendered HTML from a trusted source):

Variables, literals, and expressions

Inside output and {% %} tags, Vision accepts:

Conditionals

Branch on a truthy/falsy expression. elseif and else are optional.

Supported operators: ==, !=, >, <, >=, <=, and, or, not.

Vision uses its own truthiness rules — see Notes & Gotchas.

Loops

Iterate over any iterable value — arrays, Traversable objects, and generators all work:

If the value is not iterable, the loop body is skipped and emits nothing.

Filters

Filters transform a value using the | pipe syntax, and they chain left-to-right:

Built-in filters

Filter Arguments Behavior
default(fallback) fallback default '' Returns fallback when the value is null, '', or false. 0, '0', and [] are not treated as empty.
upper mb_strtoupper (UTF-8 safe).
lower mb_strtolower (UTF-8 safe).
date(format) format default 'Y-m-d' Formats a numeric timestamp or any strtotime-parseable string. Returns the input unchanged if parsing fails.
number_format(decimals) decimals default 0 PHP's number_format with default , thousands and . decimal separators.
excerpt(length) length default 150 Strips tags, then truncates to length characters, trims trailing punctuation/whitespace, and appends . Strings already shorter than length are returned with tags stripped.
strip_tags PHP's strip_tags.
nl2br PHP's nl2br. Use with {! !} so the inserted <br> is not escaped.
md5 md5() of the string form of the value.
count count() of any array or Countable; 0 otherwise.
raw Marker that tells {{ }} to skip escaping. Only meaningful as the final filter in the chain.

Unknown filter names return the input unchanged — no error.

Custom filters

Custom filters receive the piped value as their first argument; any arguments in parentheses follow.

Custom tags

Custom tags are plain function calls inside a {% %} block — useful for URL helpers, site-wide values, translation lookups, and similar:

Arguments are whitespace-separated and may be any expression (literal, variable, filter chain). No tags are registered by default. Unregistered tags produce no output — no warning, no exception, no placeholder.

Template inheritance

Define a parent layout with one or more {% block %}...{% endblock %} regions:

layout.tpl

A child template declares {% extends %} and overrides whichever blocks it cares about:

page.tpl

Blocks the child does not override fall through to the parent's default content.

Includes

Pull one template into another:

Included templates inherit the parent's full variable scope. The optional with { key: value, ... } clause adds or overrides variables for the included template only — the parent's scope is not mutated.

Missing includes silently produce no output. When using the with clause, the template name must be a quoted string (see Notes & Gotchas).

The Engine API

new Engine()

Takes no arguments. Create one instance per application and reuse it.

Engine::render(string $templatePath, array $data, ?string $basePath = null): string

Parameter Purpose
$templatePath Absolute path to the .tpl file to render.
$data Variable context exposed to the template.
$basePath Optional base directory for resolving {% include %} and {% extends %} names. Defaults to dirname($templatePath) . '/'.

Returns the rendered string, or '' if $templatePath does not exist.

Set $basePath explicitly when your layouts or partials live in a different directory from the template being rendered — for example, a shared views/layouts/ tree referenced from module-local templates:

Engine::filters(): FilterRegistry

Returns the filter registry. Call ->register(string $name, callable $callback) to add custom filters.

Engine::tags(): TagRegistry

Returns the tag registry. Call ->register(string $name, callable $callback) to add custom tags.

File Extension

Templates use the .tpl extension by convention. Include and extends names have .tpl appended automatically if not present, so both {% include 'partials/sidebar' %} and {% include 'partials/sidebar.tpl' %} resolve to the same file.

Security

Notes & Gotchas

These are the specific behaviors most likely to surprise you. Nothing here is a bug — each is intentional — but they're worth knowing up front.

Tests

See TESTS.md for the full test suite results covering output, escaping, conditionals, loops, filters, tags, includes, inheritance, literals, and security.

License

MIT


All versions of vision 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 enlivenapp/vision contains the following files

Loading the files please wait ...