Download the PHP package stougeiro/view without Composer

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

PHP PHPStan-Level Pest-php License

View

A light, engine-agnostic view layer for PHP. It resolves view identifiers (dot notation and aliases) into file paths, merges shared and local data, and renders templates through a swappable engine — all behind the stougeiro/view-contract interfaces. No global helpers, no hidden state, no cache: pure dependency injection.

✨ Features

Curious how it stacks up against Twig, Blade, Plates and friends? See the comparison.


📦 Installation

Install via Composer:

🚀 Usage Example

Basic Usage

Templates

Templates are plain PHP files. Data arrives as variables:

Directives are native PHP — if, foreach, echo, everything. No {{ }} to learn. Templates also receive $this, a TemplateContext with six methods for layout inheritance and safe output:

Method Role
echo($value) Escapes the value (ENT_QUOTES \| ENT_SUBSTITUTE, UTF-8) and returns HTML-safe output.
extends('view.name') Declares the parent layout. The first call wins.
include('admin:sidebar') Renders another view by identifier and echoes it.
block('name') Opens a block. Blocks cannot be nested.
endblock() Closes the block. The first definition wins.
yield('name', $default) Outputs a block, or $default when no one defined it.

Native echo prints raw content; $this->echo($value) is the escape by default. Prefer <?= $this->echo($var) ?> for anything that can carry user data, and keep raw echo only for markup you explicitly trust.

extends chains through any number of levels and cycles are detected. A view without extends still renders as a standalone template.

Those six methods are all a template can call — $this is a facade. The rendering machinery behind it (takeParent, enterPass, block bookkeeping) lives in the internal STDW\View\Spec\RenderContext and is unreachable from a template; calling an internal method raises a plain PHP Error.

There is a single entry point for variables: render($view, $data) plus share(). Every layout pass and every include() receives exactly that data — include() takes no extra variables. One consequence: a variable reassigned locally in a template (e.g. $title = strtoupper($title)) is not visible to the included template. Blocks are captured output; a block defined in a template without extends only appears through yield() in the same file.

Error Handling

Every failure is a named exception under STDW\View\Exception, all extending the SPL types you already catch:

Exception Extends Thrown when
ViewConfigException InvalidArgumentException The config or an alias() registration is invalid (storage and extension must be non-empty strings, alias name matching [A-Za-z0-9]).
ViewIdentifierException InvalidArgumentException The view identifier is empty, malformed, contains control characters, has more than one :, or references an unknown alias.
ViewNotFoundException RuntimeException The resolved template file does not exist on disk.
ViewRenderException RuntimeException Template inheritance or block usage is invalid (cyclic extends/include, nested/stray/unclosed blocks, extends() inside an include()).

🔒 Security Boundaries


⏳ Long-running runtimes

Under PHP-FPM every request starts from a clean process, so a single instance works. In long-running runtimes — Swoole, RoadRunner, FrankenPHP — the process is reused, so treat the mutable parts as per-request:


🧠 Why?

Because a view layer should do two things well — resolve a view identifier to a file, and render it with data — without becoming a framework. PhpEngine is the proposal itself, not a stepping stone toward a fancier engine: templates are plain PHP, so there is nothing to compile or warm up. The six $this methods are the whole template surface, escape included.

The design draws a hard line: no compilation cache, no global functions, no configuration discovery, no comfort features. Just include under control — a basic, performant way to cover a simple and sufficient template engine.

That boundary is intentional. If you outgrow it — compiled templates, components, caching — you swap the engine behind ViewEngineInterface and leave the manager and your views untouched.

The goal is to offer a view layer that:


🤝 Contributions

Contributions are welcome. Feel free to open issues or submit pull requests.



All versions of view with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
stougeiro/view-contract Version ^0.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 stougeiro/view contains the following files

Loading the files please wait ...