PHPackages                             borschphp/smarty - 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. borschphp/smarty

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

borschphp/smarty
================

A smarty template engine wrapper for Borsch Framework applications.

0.1.1(4y ago)032MITPHP

Since Jun 1Pushed 4y agoCompare

[ Source](https://github.com/borschphp/borsch-smarty)[ Packagist](https://packagist.org/packages/borschphp/smarty)[ RSS](/packages/borschphp-smarty/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Borsch Smarty Template Renderer
===============================

[](#borsch-smarty-template-renderer)

[![Build Status](https://camo.githubusercontent.com/e165ecee4305e52042acf86f51372edb2ae0a06cfeb2186883eaa7d04ec9f112/68747470733a2f2f7472617669732d63692e636f6d2f626f727363687068702f626f727363682d736d617274792e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/borschphp/borsch-smarty)[![Latest Stable Version](https://camo.githubusercontent.com/a59ab54ddfcfbabf6deff49065043f807f7e85406ae4af884c2219264062fc1f/68747470733a2f2f706f7365722e707567782e6f72672f626f727363687068702f736d617274792f76)](//packagist.org/packages/borschphp/smarty)[![License](https://camo.githubusercontent.com/423abc96c371eb2fff5326e5d88a647c0508cd03c3d3a4495bed6291d1b8f7e4/68747470733a2f2f706f7365722e707567782e6f72672f626f727363687068702f736d617274792f6c6963656e7365)](//packagist.org/packages/borschphp/smarty)

An implementation of Smarty for the Borsch's TemplateRendererInterface.

This package is part of the Borsch Framework.

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

[](#installation)

Via [composer](https://getcomposer.org/) :

`composer require borschphp/smarty`

Integration in Borsch Framework
-------------------------------

[](#integration-in-borsch-framework)

Open the file `config/container.php` then add your TemplateRendererInterface definition.

```
use Borsch\Smarty\Smarty;
use Borsch\Template\TemplateRendererInterface;

/*
 * Template renderer definitions
 * -----------------------------
 *
 * Defining the TemplateRendererInterface here so our HomeHandler handler (see upper) can use it when instantiated.
 * The default Borsch Smarty renderer is used.
 * We cache it so that it is not re-created when fetched a second time.
 */
$container->set(TemplateRendererInterface::class, function () {
    $smarty = new Smarty();
    $smarty->setTemplateDir(__DIR__.'/../resources/templates');
    $smarty->setCompileDir(__DIR__.'/../storage/smarty/templates_c');
    $smarty->setCacheDir(__DIR__.'/../storage/smarty/cache');

    return $smarty;
})->cache(true);
```

To load it in your handler, add it as a parameter of the constructor :

```
class HomeHandler implements RequestHandlerInterface
{

    /** @var TemplateRendererInterface */
    protected $renderer;

    /**
     * HomeHandler constructor.
     * @param TemplateRendererInterface $renderer
     */
    public function __construct(TemplateRendererInterface $renderer)
    {
        $this->renderer = $renderer;
    }

    /**
     * @inheritDoc
     */
    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        return new HtmlResponse($this->renderer->render('home'));
    }
}
```

Usage
-----

[](#usage)

```
$smarty = new \Borsch\Smarty\Smarty();

// Adding some directories where templates are located
$smarty->addPath(__DIR__.'/templates');
$smarty->addPath(__DIR__.'/templates/error', 'error');
$smarty->addPath(__DIR__.'/templates/success', 'success');

// Assign some variables
$smarty->assign([
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3'
]);

// Display the template (with or without .tpl extension)
echo $smarty->render('template_file_name');
```

License
-------

[](#license)

The package is licensed under the MIT license. See [License File](https://github.com/borschphp/borsch-smarty/blob/master/LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Total

2

Last Release

1549d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e1a70117520fe10a630d61c750bbe6888d174e9903825e741470f818ee2c5d1?d=identicon)[debuss-a](/maintainers/debuss-a)

---

Top Contributors

[![debuss](https://avatars.githubusercontent.com/u/2537607?v=4)](https://github.com/debuss "debuss (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/borschphp-smarty/health.svg)

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

###  Alternatives

[modx/revolution

MODX Revolution is a Content Management System

1.4k9.1k12](/packages/modx-revolution)[ytake/laravel-smarty

Smarty template engine for Laravel and Lumen

87401.6k](/packages/ytake-laravel-smarty)[noiselabs/smarty-bundle

This Symfony bundle provides integration for the Smarty3 template engine.

53194.4k1](/packages/noiselabs-smarty-bundle)

PHPackages © 2026

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