PHPackages                             franz-deleon/fdl-construct-invoker - 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. franz-deleon/fdl-construct-invoker

ActiveLibrary

franz-deleon/fdl-construct-invoker
==================================

A ZF2 module that enables argument passing to class constructors with arguments at construction time.

1.0(12y ago)024MITPHPPHP &gt;=5.3.3

Since Sep 29Pushed 12y ago1 watchersCompare

[ Source](https://github.com/franz-deleon/FdlConstructInvoker)[ Packagist](https://packagist.org/packages/franz-deleon/fdl-construct-invoker)[ Docs](https://github.com/franz-deleon/ConstructInvoker)[ RSS](/packages/franz-deleon-fdl-construct-invoker/feed)WikiDiscussions master Synced today

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

FdlConstructInvoker
===================

[](#fdlconstructinvoker)

A ZF2 module that enables argument passing to class constructors (`__construct()`) that requires or not require arguments at construction time.

Quick glimpse:

```
// syntax
$this->getServiceLocator()->get('MyInvokableClass')->construct([$firstArg [, $secondArg [, $...]]]);

```

INSTALLATION:
-------------

[](#installation)

Register FdlConstructInvoker module in application.config.php. It is **important** to note that you need to have the module loaded first **BEFORE** other modules who uses it!

```
    return array(
      'modules' => array(
          'FdlConstructInvoker', //  array(
              './module',
              './vendor'
          ),
          'config_glob_paths' => array('config/autoload/{,*.}{global,local}.php')
      )
    );

```

USAGE:
------

[](#usage)

An example class that you want to register to the service manager.
Notice the class requires a `$brick` instance in its constructor.

```
    namespace class\namespace;
    class Brick
    {
        protected $brick;

        public function __construct($brick)
        {
            $this->brick = $brick;
        }

        public function getBrick()
        {
            return $this->brick;
        }

        public function setBrick($briok)
        {
            $this->brick = $brick;
        }
    }

```

Register your invokable classes in your modules using the provided `getConstructInvokerConfig()` method.

```
    // Module.php of Application module
    public function getConstructInvokerConfig()
    {
        return array(
            'invokables' => array(
                'brick' => 'class\namespace\Brick',
            ),
        );
    }

```

Now you can access the class anywhere you have the main ServiceManager. For example, inside a controller.
Take note of the `get('brick')->construct()` method whick accepts arguments for the constructor.

```
    // from an action controller
    public function SomeAction()
    {
        // access it directly from the ServiceManager
        $brick = $this->getServiceLocator()->get('brick')->construct('Concrete Brick');
        echo $brick->getBrick();
        // returns "Concrete Brick"

        // you can also access through the Construct Invoker plugin manager
        $brick2 = $this->getServiceLocator()
                       ->get('constructInvokerPlugin')
                       ->get('brick')
                       ->construct('Hollow Blocks');
        echo $brick2->getBrick();
        // creates new instance of brick object and returns "Hollow Blocks"

        // same instance of brick
        echo $brick->getBrick(); // returns "Concrete Brick"
        $brick->setBrick('Marbles');
        echo $brick->getBrick() // returns "Marbles"
    }

```

It will also work for regular invokable classes that are not using constructors:

```
    // pretend SomeClass is registered using getConstructInvokerConfig()
    echo $this->getServiceConfig->get('SomeClass')->someMethod(); // whatever somemethod does...

```

UNDER THE HOOD
--------------

[](#under-the-hood)

FdlConstructInvoker module uses the Peering Service Manager functionality of the Service Manager. Modules who disable this may not be able to do directy below:

```
$this->getServiceLocator()->get('someclass')->construct()

```

If this is the case. Use the Construct Invoker Plugin Manager:

```
$this->getServiceLocator()->get('constructInvokerPlugin')->get('someclass')->construct();

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

4606d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/59b9877135752fc1bb4f1a171a1d29e0feba8d3c9c62d9cb13914b2b6b3e50a4?d=identicon)[franz-deleon](/maintainers/franz-deleon)

---

Top Contributors

[![franz-deleon](https://avatars.githubusercontent.com/u/715451?v=4)](https://github.com/franz-deleon "franz-deleon (17 commits)")

---

Tags

zf2Zend Frameworkzf2 constructorconstructor initializationadding constructor arguments

### Embed Badge

![Health badge](/badges/franz-deleon-fdl-construct-invoker/health.svg)

```
[![Health](https://phpackages.com/badges/franz-deleon-fdl-construct-invoker/health.svg)](https://phpackages.com/packages/franz-deleon-fdl-construct-invoker)
```

###  Alternatives

[zfr/zfr-cors

Zend Framework module that let you deal with CORS requests

611.2M3](/packages/zfr-zfr-cors)[facile-it/sentry-module

This module allows integration of Sentry Client into laminas and mezzio

19372.5k](/packages/facile-it-sentry-module)[maglnet/magl-markdown

Provides a ZF2 View Helper to render markdown syntax. It uses third-party libraries for the rendering and you can switch between different renderers.

22178.2k4](/packages/maglnet-magl-markdown)[thomasvargiu/rabbitmq-module

Integrates php-amqplib with Zend Framework 2 and RabbitMq

15143.0k1](/packages/thomasvargiu-rabbitmq-module)[snapshotpl/zf-snap-php-debug-bar

PHP Debug Bar module for Zend Framework 2

3026.1k](/packages/snapshotpl-zf-snap-php-debug-bar)[mcn/elastic-search

A module that helps integration of elastic search

191.1k](/packages/mcn-elastic-search)

PHPackages © 2026

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