PHPackages                             pollen-solutions/partial - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. pollen-solutions/partial

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pollen-solutions/partial
========================

Pollen Solutions - Partial Component - Layer and tools for creating reusable web user interfaces.

v1.0.2(4y ago)0293MITPHPPHP ^7.4 || ^8.0

Since Aug 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/pollen-solutions/partial)[ Packagist](https://packagist.org/packages/pollen-solutions/partial)[ Docs](https://www.presstify.com/pollen-solutions/partial/)[ RSS](/packages/pollen-solutions-partial/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (4)Used By (3)

Partial Component
=================

[](#partial-component)

[![Latest Stable Version](https://camo.githubusercontent.com/8ea46c281937466a90f569efdda5fd7f0cbc548fefeca8be43945e4dd07a3083/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f6c6c656e2d736f6c7574696f6e732f7061727469616c2e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/pollen-solutions/partial)[![MIT Licensed](https://camo.githubusercontent.com/daa52099573be5a50c320c4387496400f2f722e49f86a42db8d5778130d3582d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f7374796c653d666f722d7468652d6261646765)](LICENSE.md)[![PHP Supported Versions](https://camo.githubusercontent.com/d9d71d0b69072c51e1ff7adfdb6270f896f75787500ce6437120e23727c081d1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d372e342d3838393242463f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://www.php.net/supported-versions.php)

Pollen Solutions **Partial** Component provides layer and tools for creating reusable web user interfaces.

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

[](#installation)

```
composer require pollen-solutions/partial
```

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

[](#basic-usage)

### From a callable

[](#from-a-callable)

```
use Pollen\Partial\PartialManager;

$partial = new PartialManager();

$partial->register('hello', function () {
    return 'Hello World !';
});

echo $partial->get('hello');
```

### From the default partial tag driver

[](#from-the-default-partial-tag-driver)

```
use Pollen\Partial\PartialManager;

$partial = new PartialManager();

$partial->register('hello');

echo $partial->get('hello', ['content' => 'Hello World !']);
```

### From a custom driver

[](#from-a-custom-driver)

```
use Pollen\Partial\PartialDriver;
use Pollen\Partial\PartialManager;

class HelloPartial extends PartialDriver
{
    public function render() : string{
        return 'Hello World !';
    }
}

$partial = new PartialManager();

$partial->register('hello', HelloPartial::class);

echo $partial->get('hello');
```

### Through a PSR-11 depency injection container

[](#through-a-psr-11-depency-injection-container)

```
use Pollen\Container\Container;
use Pollen\Partial\PartialDriver;
use Pollen\Partial\PartialManager;

$container = new Container();

$partial = new PartialManager();
$partial->setContainer($container);

class HelloPartial extends PartialDriver
{
    public function render() : string{
        return 'Hello World !';
    }
}

$container->add('helloPartialService', HelloPartial::class);

$partial->register('hello', 'helloPartialService');

echo $partial->get('hello');
```

### Shows a partial driver instance with custom parameters

[](#shows-a-partial-driver-instance-with-custom-parameters)

```
use Pollen\Partial\PartialDriverInterface;
use Pollen\Partial\PartialManager;

$partial = new PartialManager();

$partial->register('hello', function (PartialDriverInterface $driver) {
    return 'Hello '. $driver->get('name') .' !';
});

echo $partial->get('hello', ['name' => 'John Doe']);
```

### Recalls the same partial driver instance with keeped custom parameters

[](#recalls-the-same-partial-driver-instance-with-keeped-custom-parameters)

```
use Pollen\Partial\PartialDriverInterface;
use Pollen\Partial\PartialManager;

$partial = new PartialManager();

$partial->register('hello', function (PartialDriverInterface $driver) {
    return 'Hello '. $driver->get('name') .' !';
});

echo $partial->get('hello', 'HelloJohn', ['name' => 'John Doe']);
echo $partial->get('hello', 'HelloJane', ['name' => 'Jane Doe']);
echo $partial->get('hello', 'HelloJohn');
```

Partial driver API
------------------

[](#partial-driver-api)

### Partial driver parameters of call

[](#partial-driver-parameters-of-call)

```
use Pollen\Partial\PartialDriverInterface;
use Pollen\Partial\PartialManager;

$partial = new PartialManager();

$tag = $partial->get('tag', [
    /**
     * Common driver parameters.
     * --------------------------------------------------------------------------
     */
    /**
     * Main container HTML tag attributes.
     * @var array $attrs
     */
    'attrs'   => [
        'class' => '%s MyAppendedClass'
    ],
    /**
     * Content displayed after the main container.
     * @var string|callable $after
     */
    'after'   => 'content show after',
    /**
     * Content displayed before the main container.
     * @var string|callable $before
     */
    'before'  => function (PartialDriverInterface $driver) {
        return 'content show before'
    },
    /**
     * List of parameters of the template view|View instance.
     * {@internal See below in the View API usage section.}
     * @var array|ViewInterface $view
     */
    'view'  => [],

    /**
     * Tag partial driver parameters
     * --------------------------------------------------------------------------
     */
    /**
     * HTML tag.
     * @var string $tag div|span|a|... default div.
     */
    'tag'       => 'div',
    /**
     * HTML tag content.
     * @var string|callable $content
     */
    'content'   => '',
    /**
     * Enable tag as singleton.
     * {@internal Auto-resolve if null based on list of known singleton tags.}
     * @var bool|null $singleton
     */
    'singleton' => null,
]);

echo $tag;
```

### Partial driver instance methods

[](#partial-driver-instance-methods)

```
use Pollen\Field\FieldManager;

$field = new FieldManager();

$field->register('hello', function () {
    return 'Hello World';
});

if ($hello = $partial->get('hello')) {
    // Gets alias identifier.
    printf('alias: %s ', $hello->getAlias());

    // Gets the base prefix of HTML class.
    printf('base HTML class: %s ', $hello->getBaseClass());

    // Gets the unique identifier.
    printf('identifier: %s ', $hello->getId());

    // Gets the index in related partial manager.
    printf('index: %s ', $hello->getIndex());
}
```

### View API usage

[](#view-api-usage)

#### Plates view engine

[](#plates-view-engine)

Partial driver used Plates as default template engine.

1. Creates a view file for the partial driver.

```
// /var/www/html/views/partial/hello.plates.php file
/**
 * \Pollen\Partial\PartialTemplateInterface $this
 */
echo 'Hello World !';
```

2. Creates and call a partial driver with this above file directory as view directory.

```
use Pollen\Partial\PartialDriver;
use Pollen\Partial\PartialManager;

$partial = new PartialManager();

$partial->register('hello', new class extends PartialDriver{});

echo $partial->get('hello', ['view' => [
    /**
     * View directory absolute path (required).
     * @var string
     */
    'directory' => '/var/www/html/views/partial/',
    /**
     * View override directory absolute path.
     * @var string|null
     */
    'override_dir' => null,
    /**
     * View render main template name. index is used by default if its null.
     * @var string|null
     */
    'template_name' => 'hello'
]]);
```

#### Uses another view engine

[](#uses-another-view-engine)

Your are free to used your own instance of Pollen\\View\\ViewInterface as the partial driver view parameter if needed. In this example Twig engine is used instead Plates.

1. Creates a view file for the partial driver.

```

Hello World !
```

2. Creates and call a partial driver with this above file directory as view directory.

```
use Pollen\View\ViewManager;
use Pollen\Partial\PartialDriver;
use Pollen\Partial\PartialManager;

$partial = new PartialManager();

$partial->register('hello', new class extends PartialDriver{});

$viewEngine = (new ViewManager())->createView('twig')->setDirectory('/var/www/html/views/partial/hello/');

echo $partial->get('hello', ['view' => $viewEngine]);
```

### Routing API usage

[](#routing-api-usage)

In some cases, partial driver should be able to send a response through a controller, for example to respond from a rest api call.

Fortunately, all partial driver instance are related to a route stack and have a reponseController method to do that. The partial driver route stack is created for all known HTTP methods (GET, POST, PATH, OPTIONS, DELETE) and for a particular api method that works with XHR HTTP request.

1. Creates a partial driver and gets its route url for the get http method.

```
use Pollen\Http\Response;
use Pollen\Http\ResponseInterface;
use Pollen\Partial\PartialDriver;
use Pollen\Partial\PartialManager;

$partial = new PartialManager();

$partial->register('hello', new class extends PartialDriver {
    public function responseController(...$args) : ResponseInterface {
        return new Response('Hello World !');
    }
});

// Gets the route url for the get HTTP method
echo $partial->getRouteUrl('hello', null, [], 'get');
```

2. Now you can call the route url in your browser.

[Get the partial response](/_partial/hello/responseController)

Obviously, you are free to use your own routing stack and them controller methods instead.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Total

3

Last Release

1726d ago

### Community

Maintainers

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

---

Top Contributors

[![jordy-manner](https://avatars.githubusercontent.com/u/733356?v=4)](https://github.com/jordy-manner "jordy-manner (9 commits)")

---

Tags

partialphpuicomponentpartialpollen-solutionsuser interfacesuix

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pollen-solutions-partial/health.svg)

```
[![Health](https://phpackages.com/badges/pollen-solutions-partial/health.svg)](https://phpackages.com/packages/pollen-solutions-partial)
```

###  Alternatives

[livewire/flux

The official UI component library for Livewire.

9385.0M85](/packages/livewire-flux)

PHPackages © 2026

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