Download the PHP package nixphp/view without Composer

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

![Logo](https://nixphp.github.io/docs/assets/nixphp-logo-small-square.png) [![NixPHP View Plugin](https://github.com/nixphp/view/actions/workflows/php.yml/badge.svg)](https://github.com/nixphp/view/actions/workflows/php.yml)

← Back to NixPHP


nixphp/view

A lightweight, native PHP templating system — with layout inheritance and block support.

This plugin brings a clean, minimal templating system to your NixPHP application. It lets you define base layouts, use content blocks, and safely output user data — all with pure PHP.

🧩 Part of the official NixPHP plugin collection. Install it when you need structured HTML rendering — without external engines like Twig or Blade.


📦 Features


📥 Installation

The plugin auto-registers itself and adds the view(), render(), assets() and s() helpers globally.


🚀 Usage

🧱 Rendering views

Use the view() helper to render a template and return the result as a string:

This is useful if you want to process or wrap the HTML manually.

Use the render() helper to return a response object instead (e.g. in your controller):

This renders the view and wraps it in a proper response, ready to be returned from any route handler.

To load a template file in another folder, you can use the dot notation:

Or even multiple levels:

This works for both view() and render().


🧩 Layouts & Blocks

Use setLayout() to define a parent layout, and block()/endblock() to inject content:

views/page.phtml

views/layout.phtml


🛡️ Escape output

Use the s() helper to sanitize output (HTML-escaped):


🎨 Asset Management (CSS & JS)

The plugin includes a small, flexible asset collector used inside layouts to include CSS and JavaScript files.

Assets are added inside views or controllers using the assets() helper:

Output in layout files

Use assets()->render('css') or assets()->render('js') inside your layout:

What gets generated?

CSS:

Classic JS:

Module JS:

Internals

All paths are automatically HTML-escaped via s().


🔁 Helper Comparison

Helper Returns Use case
render() ResponseInterface Ideal for controller return values
view() string For manual output or further processing
assets() string Include CSS & JS files in layouts
s() string Escape output

🔍 Internals

⚙️ Configurable view locations

Set the view:paths configuration to control where templates are resolved inside your application. This plugin ships with src/config.php, which defaults to:

The entries are resolved relative to BASE_PATH when they are not absolute paths, so you can place templates anywhere and order them however you need. The plugin checks each directory in order before falling back to registered plugin or framework view paths.


✅ Requirements


📄 License

MIT License.


All versions of view with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
nixphp/framework Version ^0.1.0
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 nixphp/view contains the following files

Loading the files please wait ...