PHPackages                             italystrap/view - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. italystrap/view

ActiveLibrary[Templating &amp; Views](/categories/templating)

italystrap/view
===============

View API for loading template parts and views the OOP way

1.1.3(6mo ago)0664[3 issues](https://github.com/ItalyStrap/view/issues)MITPHPPHP &gt;=7.2

Since Nov 25Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/ItalyStrap/view)[ Packagist](https://packagist.org/packages/italystrap/view)[ RSS](/packages/italystrap-view/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (5)Dependencies (24)Versions (6)Used By (0)

ItalyStrap View API
===================

[](#italystrap-view-api)

[![Build Status](https://camo.githubusercontent.com/3cb42ce1b35721919fda7fcbfb749420c5e80dc6d79702de3ac4c9f68d767453/68747470733a2f2f7472617669732d63692e6f72672f4974616c7953747261702f766965772e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ItalyStrap/view)[![Latest Stable Version](https://camo.githubusercontent.com/47a36114d29b35970e286dd147135f9756f2db72d830402884222348f97b7193/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6974616c7973747261702f766965772e737667)](https://packagist.org/packages/italystrap/view)[![Total Downloads](https://camo.githubusercontent.com/de22126bd8f4f1bd52a56b9bb85516b99e5dabbc1e95655209334e28676e57e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6974616c7973747261702f766965772e737667)](https://packagist.org/packages/italystrap/view)[![Latest Unstable Version](https://camo.githubusercontent.com/a1729119f609297fea9978564f92080b24c9acd55f661df794a38b33c7f92b2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6974616c7973747261702f766965772e737667)](https://packagist.org/packages/italystrap/view)[![License](https://camo.githubusercontent.com/1570f9313891d84e7a985123af79163a724116aec82f6d72063f11415310a626/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6974616c7973747261702f766965772e737667)](https://packagist.org/packages/italystrap/view)[![PHP from Packagist](https://camo.githubusercontent.com/97418017b36d62ef02a952c4300e9071039941100b9a98bf4d68f1423cc9fabc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6974616c7973747261702f76696577)](https://camo.githubusercontent.com/97418017b36d62ef02a952c4300e9071039941100b9a98bf4d68f1423cc9fabc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6974616c7973747261702f76696577)

PHP Sanitizer and Validation OOP way

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Advanced Usage](#advanced-usage)
- [Contributing](#contributing)
- [License](#license)

Installation
------------

[](#installation)

The best way to use this package is through Composer:

```
composer require italystrap/view
```

Basic Usage
-----------

[](#basic-usage)

```
$finder = new \ItalyStrap\View\ViewFinder();

$finder->in( 'full/path/to/the/views/' );
//or
$finder->in( ['full/path/to/the/views/','full/path/to/the/views/'] );

$view = new \ItalyStrap\View\View( $finder );

$view->render( 'slug', $data ); // Data could be the type of: string|int|array|object
// Or
$view->render( ['slug'], $data );
// Or
$view->render( ['slug', 'name'], $data );
// Or
$view->render( ['slug', 'name', 'subName'], $data );
```

### For WordPress User

[](#for-wordpress-user)

By default it will search in child -&gt; parent -&gt; theme-compat directories like the original `\get_template_part()` does

```
// It will search in the root of your theme slug-name.php -> slug.php
\ItalyStrap\View\get_template_part( 'slug', 'name', $data );

// Or

use ItalyStrap\View;

// theme_path/slug-name.php
// theme_path/slug.php
get_template_part( 'slug', 'name', $data );

// theme_path/slug-slug1-name.php
// theme_path/slug-name.php
// theme_path/slug.php
get_template_part( ['slug', 'slug1'], 'name', $data );
```

If you need to add more or different direcories for searchinf files you can filter theme with the `'italystrap_view_get_template_part_directories'` hook.

```
\add_filter( 'italystrap_view_get_template_part_directories', function( array $dirs ) {
    // Add here your logic for dirs
    // For example you can add subdirs or remove dirs
    // You can add directories for languages
    // You can add directories from plugins and so on.
    // The sky is the limit.

    return $dirs;
});
```

Some example of results:

plugin\_path/some\_dir\_path/slug-name.php plugin\_path/some\_dir\_path/slug.php theme\_path/other\_dir\_path/slug-slug-name.php theme\_path/other\_dir\_path/slug-name.php theme\_path/other\_dir\_path/slug.php

theme\_with\_locale\_path/locale/slug-name.php

And so on.

### Inside the file template

[](#inside-the-file-template)

Inside the file or template part you require if you added some $data value you can use it like so:

```
$data = [
    'title' => 'Ciao Mondo',
];

// some-template-part.php
use ItalyStrap\View;
get_template_part( ['some','template'], 'part', $data );
//or
//...
//$view->render( ['some','template','part'], $data );

// inside some-template-part.php
echo $this->title;

//or

echo $this->get( 'title', 'Some default title' );
```

Advanced Usage
--------------

[](#advanced-usage)

See in [Tests Foldes](tests)

Contributing
------------

[](#contributing)

All feedback / bug reports / pull requests are welcome.

License
-------

[](#license)

Copyright (c) 2019 Enea Overclokk, ItalyStrap

This code is licensed under the [MIT](LICENSE).

Credits
-------

[](#credits)

For the Closure in the View and for some ideas with the Symphony Finder

- [Giuseppe Mazzapica](https://github.com/gmazzap)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance66

Regular maintenance activity

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~541 days

Total

5

Last Release

200d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.1

1.1.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/13d145319a065be260ee79e728655780ddd63002e5ac6c317701c8996ec8d94c?d=identicon)[overclokk](/maintainers/overclokk)

---

Top Contributors

[![overclokk](https://avatars.githubusercontent.com/u/4604932?v=4)](https://github.com/overclokk "overclokk (31 commits)")

---

Tags

phpphp-libraryviewwordpress-php-librarytemplateviewrenderer

###  Code Quality

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/italystrap-view/health.svg)

```
[![Health](https://phpackages.com/badges/italystrap-view/health.svg)](https://phpackages.com/packages/italystrap-view)
```

###  Alternatives

[eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

8208.4M87](/packages/eftec-bladeone)[jenssegers/blade

The standalone version of Laravel's Blade templating engine for use outside of Laravel.

8661.2M109](/packages/jenssegers-blade)[wyrihaximus/twig-view

Twig powered View for CakePHP

804.7M1](/packages/wyrihaximus-twig-view)[anourvalar/office

Generate documents from existing Excel &amp; Word templates | Export tables to Excel (Grids)

24085.2k](/packages/anourvalar-office)[ytake/laravel-smarty

Smarty template engine for Laravel and Lumen

87401.6k](/packages/ytake-laravel-smarty)[aura/view

Provides an implementation of the TemplateView and TwoStepView patterns, with support for helpers and for closures as templates, using PHP itself as the templating language.

88152.8k19](/packages/aura-view)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
