PHPackages                             inteve/simple-components - 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. inteve/simple-components

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

inteve/simple-components
========================

Simple components for Latte templates

v1.0.0(2y ago)12.4k[1 PRs](https://github.com/inteve/simple-components/pulls)BSD-3-ClausePHPPHP &gt;=5.6.0CI failing

Since Mar 30Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/inteve/simple-components)[ Packagist](https://packagist.org/packages/inteve/simple-components)[ Fund](https://www.janpecha.cz/donate/)[ RSS](/packages/inteve-simple-components/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

Inteve\\SimpleComponents
========================

[](#intevesimplecomponents)

[![Build Status](https://github.com/inteve/simple-components/workflows/Build/badge.svg)](https://github.com/inteve/simple-components/actions)[![Downloads this Month](https://camo.githubusercontent.com/460442498cbc85ba69322f96e83d9a3c5504a44ed30fab2202050c8245ee8ee1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f696e746576652f73696d706c652d636f6d706f6e656e74732e737667)](https://packagist.org/packages/inteve/simple-components)[![Latest Stable Version](https://camo.githubusercontent.com/b8276c869d984ad7bb5df29f38af73733b4389483ffb96d93c212d9d030b82cb/68747470733a2f2f706f7365722e707567782e6f72672f696e746576652f73696d706c652d636f6d706f6e656e74732f762f737461626c65)](https://github.com/inteve/simple-components/releases)[![License](https://camo.githubusercontent.com/fa7d5fcf2c84b580327af52da95dd751703af65f079dc3c5a0081beac0789718/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4e65772532304253442d626c75652e737667)](https://github.com/inteve/simple-components/blob/master/license.md)

Simple independent components for Latte templates.

[![Donate](https://camo.githubusercontent.com/101b981194f1dafbf9c42e19c3034fe2d724e75be972cef0f4477074997834db/68747470733a2f2f6275796d65636f666665652e696e746d2e6f72672f696d672f646f6e6174652d62616e6e65722e76312e737667)](https://www.janpecha.cz/donate/)

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

[](#installation)

[Download a latest package](https://github.com/inteve/simple-components/releases) or use [Composer](http://getcomposer.org/):

```
composer require inteve/simple-components

```

Inteve\\SimpleComponents requires PHP 8.0 or later.

Usage
-----

[](#usage)

### 1. create components factory

[](#1-create-components-factory)

```
use Inteve\SimpleComponents;

class MyComponentFactory implements SimpleComponents\ComponentFactory
{
	public function create($componentName, array $args = [])
	{
		if ($componentName === 'menu') {
			return new SimpleComponents\GenericComponent(__DIR__ . '/components/Menu.latte');

		} elseif ($componentName === 'breadcrumbs') {
			return new SimpleComponents\GenericComponent(__DIR__ . '/components/Breadcrumbs.latte', $args);
		}

		return NULL;
	}
}
```

### 2. register `{component}` macro

[](#2-register-component-macro)

**In plain PHP:**

```
$latte = new Latte\Engine;
$componentFactory = new MyComponentFactory;
\Inteve\SimpleComponents\LatteMacros::installToLatte($latte, $componentFactory);
```

**In Nette presenter:**

```
abstract class BasePresenter extends \Nette\Application\UI\Presenter
{
	/** @var \Inteve\SimpleComponents\ComponentFactory @inject */
	public $componentFactory;

	protected function createTemplate()
	{
		$template = parent::createTemplate();
		assert($template instanceof \Nette\Bridges\ApplicationLatte\Template);
		\Inteve\SimpleComponents\LatteMacros::installToLatte($template->getLatte(), $this->componentFactory);
		return $template;
	}
}
```

### 3. use it in your app template

[](#3-use-it-in-your-app-template)

```
{block content}
	My Page

	{component menu}
	{component breadcrumbs, items => $breadcrumbItems}

	Lorem ipsum dolor sit amet.
{/block}
```

Prepared implementations
------------------------

[](#prepared-implementations)

### `DirectoryFactory`

[](#directoryfactory)

Loads template files from specified directory.

```
/app
	/components
		breadcrumbs.latte
		menu.latte

```

```
$componentFactory = new SimpleComponents\DirectoryFactory('/path/to/app/components');
```

```
{component menu}
{component breadcrumbs}
```

### `MultiFactory`

[](#multifactory)

Packs multiple `ComponentFactory` implementations to one class.

```
$componentFactory = new SimpleComponents\MultiFactory([
	new MyComponentFactory,
	new SimpleComponents\DirectoryFactory('/path/to/app/components')
]);
```

```
{component menu}
{component breadcrumbs}
{component someMyComponent}
```

Typed templates
---------------

[](#typed-templates)

```
class Breadcrumbs implements SimpleComponents\Component
{
	/** @var BreadcrumbItem[] */
	private $items;

	/**
	 * @param BreadcrumbItem[] $items
	 */
	public function __construct(array $items)
	{
		$this->items = $items;
	}

	public function getFile()
	{
		return __DIR__ . '/components/breadcrumbs.latte';
	}

	public function getParameters()
	{
		return [
			'items' => $this->items;
		];
	}
}

class MyComponentFactory implements SimpleComponents\ComponentFactory
{
	public function create($componentName, array $args = [])
	{
		if ($componentName === 'breadcrumbs') {
			return new Breadcrumbs($args['items']);
		}

		return NULL;
	}
}
```

```
{component breadcrumbs, items => $breadcrumbsItems}
```

---

License: [New BSD License](license.md)
Author: Jan Pecha,

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~158 days

Recently: every ~145 days

Total

6

Last Release

1083d ago

Major Versions

v0.2.2 → v1.0.02023-05-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c980b1511b4a0350442dc23d89c99d4d9a2411b7e765d52c133ccacf616968b?d=identicon)[janpecha](/maintainers/janpecha)

---

Top Contributors

[![janpecha](https://avatars.githubusercontent.com/u/637719?v=4)](https://github.com/janpecha "janpecha (27 commits)")

---

Tags

lattenettenette-lattephp

### Embed Badge

![Health badge](/badges/inteve-simple-components/health.svg)

```
[![Health](https://phpackages.com/badges/inteve-simple-components/health.svg)](https://phpackages.com/packages/inteve-simple-components)
```

###  Alternatives

[contributte/latte

Extra contrib to nette/latte

111.5M2](/packages/contributte-latte)[nepada/form-renderer

Latte template based form renderer for Nette forms with full support for Bootstrap 3, 4 &amp; 5.

11251.0k](/packages/nepada-form-renderer)[nextras/forms-rendering

Rendering helpers for Nette Framework Forms.

1698.4k2](/packages/nextras-forms-rendering)[webrouse/n-asset-macro

Asset macro for Latte and Nette Framework useful for assets cache busting (with gulp, webpack, etc.)

1264.4k1](/packages/webrouse-n-asset-macro)

PHPackages © 2026

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