PHPackages                             mugomes/miphanttpl - 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. mugomes/miphanttpl

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

mugomes/miphanttpl
==================

Gera HTML de forma dinâmica com PHP.

3.0.0(4mo ago)111MITPHP

Since Oct 28Pushed 4mo agoCompare

[ Source](https://github.com/mugomes/miphanttpl)[ Packagist](https://packagist.org/packages/mugomes/miphanttpl)[ RSS](/packages/mugomes-miphanttpl/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

MiPhantTPL
==========

[](#miphanttpl)

**MiPhantTPL** é uma biblioteca PHP **leve, extensível e minimalista** para geração de HTML através de **métodos dinâmicos**, permitindo escrever HTML de forma **programática, fluente e sem templates externos**.

Cada método chamado representa uma **tag HTML**, funcionando como uma **DSL (Domain Specific Language)** para HTML em PHP.

---

✨ Características
-----------------

[](#-características)

- Geração dinâmica de HTML via `__call`
- Cada método representa uma *tag HTML*
- Suporte automático a:
    - Tags que não possuem fechamento (`img`, `br`, `input`, entre outros)
    - Atributos booleanos (`checked`, `disabled`, `required`, entre outros)
- Possibilidade de **estender tags auto-fecháveis**
- Possibilidade de **estender atributos sem valor**
- Paradigma funcional
- Zero dependências
- Código pequeno, previsível e fácil de integrar

---

📦 Instalação
------------

[](#-instalação)

### Via Composer

[](#via-composer)

```
composer require mugomes/miphanttpl
```

### Manual

[](#manual)

Copie o arquivo `MiPhantTPL.php` para seu projeto e inclua via autoload ou `require`.

---

🚀 Uso básico
------------

[](#-uso-básico)

```
use MiPhantTPL\MiPhantTPL;

$tpl = new MiPhantTPL();

echo $tpl->p('Olá mundo');
```

Resultado:

```
Olá mundo
```

---

🧱 Criando elementos HTML
------------------------

[](#-criando-elementos-html)

```
echo $tpl->h1('Título');
echo $tpl->p('Conteúdo do parágrafo');
```

```
Título
Conteúdo do parágrafo
```

---

🏷️ Atributos HTML
-----------------

[](#️-atributos-html)

Os atributos são passados como **array**:

```
echo $tpl->a(
    'Acessar site',
    ['href' => 'https://example.com', 'target' => '_blank']
);
```

```
Acessar site
```

---

✅ Atributos sem valor (booleanos)
---------------------------------

[](#-atributos-sem-valor-booleanos)

A biblioteca reconhece automaticamente atributos booleanos:

```
echo $tpl->input([
    'type' => 'checkbox',
    'checked'
]);
```

```

```

---

➕ Adicionando novos atributos sem valor
---------------------------------------

[](#-adicionando-novos-atributos-sem-valor)

Você pode estender a lista padrão de atributos booleanos:

```
$tpl->addAttributeNoValue(['inert', 'itemscope']);
```

```
echo $tpl->div(
    'Conteúdo',
    ['inert']
);
```

```
Conteúdo
```

---

🔁 Tags que não possuem fechamento
---------------------------------

[](#-tags-que-não-possuem-fechamento)

Tags como `img`, `br`, `input` e similares não recebem fechamento automaticamente:

```
echo $tpl->img([
    'src' => 'foto.jpg',
    'alt' => 'Imagem'
]);
```

```

```

---

➕ Adicionando novas tags sem fechamento
---------------------------------------

[](#-adicionando-novas-tags-sem-fechamento)

Caso você utilize elementos personalizados (ex: Web Components):

```
$tpl->addNotClose(['mycomponent']);
```

```
echo $tpl->mycomponent([
    'data-id' => '123'
]);
```

```

```

---

🧩 HTML aninhado
---------------

[](#-html-aninhado)

Como tudo retorna `string`, é possível aninhar facilmente:

```
echo $tpl->div(
    $tpl->h2('Título') .
    $tpl->p('Texto do conteúdo'),
    ['class' => 'container']
);
```

---

⚙️ Uso com paradigma funcional (`code()`)
-----------------------------------------

[](#️-uso-com-paradigma-funcional-code)

O método `code()` permite escrever HTML de forma estruturada:

```
echo $tpl->code(function ($html) {
    return
        $html->doctype() .
        $html->html(
            $html->body(
                $html->h1('MiPhantTPL') .
                $html->p('Gerando HTML com PHP puro')
            )
        );
});
```

---

📄 Doctype HTML5
---------------

[](#-doctype-html5)

```
echo $tpl->doctype();
```

```
>
```

---

👤 Autor
-------

[](#-autor)

**Murilo Gomes Julio**

🔗

📺

---

📜 Licença
---------

[](#-licença)

Copyright (c) 2025-2026 Murilo Gomes Julio

Licensed under the [MIT](https://github.com/mugomes/miphanttpl/blob/main/LICENSE).

All contributions to the MiPhantTPL are subject to this license.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance77

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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

Total

3

Last Release

128d ago

Major Versions

1.0.0 → 2.0.02025-11-17

2.0.0 → 3.0.02026-01-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/e782d9d31b820ca2583dce523269edf91ef2db0d5c48af08384fad35324643cd?d=identicon)[mugomesoficial](/maintainers/mugomesoficial)

---

Top Contributors

[![mugomes](https://avatars.githubusercontent.com/u/214032302?v=4)](https://github.com/mugomes "mugomes (10 commits)")

---

Tags

htmlphptemplate

### Embed Badge

![Health badge](/badges/mugomes-miphanttpl/health.svg)

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

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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