PHPackages                             enalquiler/instanciate - 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. enalquiler/instanciate

ActiveLibrary

enalquiler/instanciate
======================

A high order function to instanciate classes passing parameters

1.0.0(8y ago)06.4k↓100%MITPHP

Since Sep 7Pushed 8y ago2 watchersCompare

[ Source](https://github.com/enalquiler/instanciate)[ Packagist](https://packagist.org/packages/enalquiler/instanciate)[ RSS](/packages/enalquiler-instanciate/feed)WikiDiscussions master Synced today

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

`instanciate`
=============

[](#instanciate)

A high order function to instanciate classes passing parameters.

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

[](#installation)

```
composer require enalquiler/instanciate

```

Usage
-----

[](#usage)

A simple example

```
use DateTimeImmutable;
use function Enalquiler\Functional\instanciate;

$fn = instanciate(DateTimeImmutable::class, 'now');
$dateTimeImmutableInstance = $fn(); // Returns an instance of DateTimeImmutable class
```

A more complex example combining the [lazy middleware function](https://github.com/enalquiler/lazy-middleware), [compose function](https://github.com/igorw/compose) to compose functions, and the awesome [functional PHP library](https://github.com/lstrojny/functional-php) to build middleware pipelines using [Zend Stratigility](https://zendframework.github.io/zend-stratigility/middleware/)

```
use Http\Factory\Diactoros\ResponseFactory;
use Zend\Diactoros\Response;
use Zend\Stratigility\MiddlewarePipe;
use function igorw\pipeline;
use function Functional\partial_right;

require_once __DIR__ . '/../vendor/autoload.php';

$pipe = new MiddlewarePipe();
$pipe->setResponsePrototype(new Response());

$lazyMiddleware = partial_right(
    pipeline(
        'Enalquiler\Functional\instanciate',
        'Enalquiler\Middleware\lazy'
    ),
    new ResponseFactory()
);

$pipe
    ->pipe($lazyMiddleware(LocaleMiddleware::class))
    ->pipe($lazyMiddleware(SessionMiddleware::class, new \PredisSessionStorage()))
    ->pipe($lazyMiddleware(RedirectionsMiddleware::class))
    ->pipe($lazyMiddleware(AdminMiddleware::class))
    ->pipe($lazyMiddleware(WebMiddleware::class))
    ->pipe($lazyMiddleware(NotFoundMiddleware::class))
;

$server = Server::createServer($app, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
$server->listen(new Zend\Stratigility\NoopFinalHandler());
```

Running the tests
-----------------

[](#running-the-tests)

```
php vendor/bin/phpunit

```

Authors
-------

[](#authors)

- **Christian Soronellas**
- **Enalquiler Engineering**

See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

###  Health Score

31

—

LowBetter than 70% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Unknown

Total

1

Last Release

3120d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/354e3452797dc73bd5de0bd46c36ee6d67df1e944c5b9671f8f93d1af952030e?d=identicon)[enalquiler](/maintainers/enalquiler)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/enalquiler-instanciate/health.svg)

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

PHPackages © 2026

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