PHPackages                             thomasvargiu/pami-module - 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. [API Development](/categories/api)
4. /
5. thomasvargiu/pami-module

ActiveLibrary[API Development](/categories/api)

thomasvargiu/pami-module
========================

ZF2 module for PAMI Asterisk Library

0.5.4(8y ago)11.2kMITPHPPHP ^5.6 || ^7.0

Since May 31Pushed 5y ago3 watchersCompare

[ Source](https://github.com/thomasvargiu/pami-module)[ Packagist](https://packagist.org/packages/thomasvargiu/pami-module)[ Docs](https://github.com/thomasvargiu/pami-module)[ RSS](/packages/thomasvargiu-pami-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (15)Versions (17)Used By (0)

PamiModule
==========

[](#pamimodule)

A ZF module for [PAMI](https://github.com/marcelog/PAMI) library.

[![Build Status](https://camo.githubusercontent.com/f6578abebeb469173f878f5e64bd983b7d60158f673f06e6bfd3a9021242402c/68747470733a2f2f7472617669732d63692e6f72672f74686f6d61737661726769752f70616d692d6d6f64756c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/thomasvargiu/pami-module)[![Code Coverage](https://camo.githubusercontent.com/0148ed935beb62ad94a10a2277f3e89f52f1fefc7945b9c03399e8e05f3dfd26/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74686f6d61737661726769752f70616d692d6d6f64756c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/thomasvargiu/pami-module/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/66325f71102b2fd5f415c11388cfa41c4de02f313fc362b7279e2af388d44038/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74686f6d61737661726769752f70616d692d6d6f64756c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/thomasvargiu/pami-module/?branch=master)[![Dependency Status](https://camo.githubusercontent.com/4f0bf40bfa540403b759616ee77e361cf03eaedc7b4fceaacbf02a6298eabb70/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3535366138333635363336353332303032363566313630302f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/556a836563653200265f1600)[![Latest Stable Version](https://camo.githubusercontent.com/8231ceab7d871dd064aeab206f6d88292b0cf20f1c6d78f869cfeaf8a04da4ac/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61737661726769752f70616d692d6d6f64756c652f762f737461626c65)](https://packagist.org/packages/thomasvargiu/pami-module)[![Total Downloads](https://camo.githubusercontent.com/325de23c9cb0ecf33b734ad36eb58cc2dcfe0c40a21870400925e765371bd93b/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61737661726769752f70616d692d6d6f64756c652f646f776e6c6f616473)](https://packagist.org/packages/thomasvargiu/pami-module)[![Latest Unstable Version](https://camo.githubusercontent.com/3388697678c5e9ec0b022b88ef774eeb2ae456f980dec0992a47e0fbe7e8f067/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61737661726769752f70616d692d6d6f64756c652f762f756e737461626c65)](https://packagist.org/packages/thomasvargiu/pami-module)[![License](https://camo.githubusercontent.com/c883d626afff1ead5853d5de719db4274484f632a77498dee2b76ff77fea7593/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61737661726769752f70616d692d6d6f64756c652f6c6963656e7365)](https://packagist.org/packages/thomasvargiu/pami-module)

Configuration
-------------

[](#configuration)

First, you should define connection and client options in your configuration. Client options are all optional.

```
return [
    'pami_module' => [
        'connection' => [
            'default' => [
                'host' => '', // IP or hostname of asterisk server
                'port' => 5038, // (optional) Asterisk AMI port (default: 5038)
                'username' => '', // Username for asterisk AMI
                'secret' => '', // Password for asterisk AMI
                'scheme' => 'tcp://', // (optional) Connection scheme (default: tcp://)
                'connect_timeout' => 10000, // (optional) Connection timeout in ms (default: 10000)
                'read_timeout' => 10000 // (optional) Read timeout in ms (default: 10000)
            ]
        ],
        'client' => [
            'default' => []
        ]
    ]
]
```

Then you can retrieve two services from the service locator:

- `pami.client.default`: PamiModule client

PamiModule Client
-----------------

[](#pamimodule-client)

You can get the client from the service locator.

```
use PamiModule\Service\Client;
use PAMI\Client\Impl\ClientImpl;

// Getting the PamiModule client
/** @var Client $client */
$client = $serviceLocator->get('pami.client.default');
```

### Methods

[](#methods)

The original `Pami` client (the connection) is injected into the `PamiModule`, and the `PamiModule` actions delegates the original client.

*Mapped Actions:*

PamiModulePAMI`connect()``open()``disconnect()``close()``sendAction()``send()``process()``process()`### Events

[](#events)

The `PamiModule` client has an `EventManager` instance injected into it.
The following methods will trigger events with the same name of the method and `.pre` and `.post` suffix:

- `connect()`
- `disconnect()`
- `process()`
- `sendAction()`

The `sendAction()` events have `action` param in `sendAction.pre` event and `action` and `response` params in `sendAction.post` event, allowing you to modify the action before it will be dispatched or to cache responses.

PAMI events
-----------

[](#pami-events)

All PAMI events are forwarded to the event manager that will trigger an event (`PamiModule\Event\PamiEvent`).
The name of the event will be `event.` (example: `event.ExtensionStatus`).
Of course, you can acces to the original event to retrieve event data (see example below).
The event target is the `PamiModule` client.

Example:

```
use PamiModule\Service\Client;
use PamiModule\Event\PamiEvent;

/* @var Client $client */
$client = $serviceLocator->get('pami.client.default');
$client->getEventManager()->attach('event.Bridge', function(PamiEvent $event) {
    // Getting the client
    /* @var Client $client */
    $client = $event->getTarget();

    // Getting the original Event
    /* @var \PAMI\Message\Event\BridgeEvent $pamiEvent */
    $pamiEvent = $event->getEvent();
});
```

Multiple clients
----------------

[](#multiple-clients)

```
return [
    'pami_module' => [
        'connection' => [
            'default' => [
                // configuration
            ],
            'asterisk2' => [
                // configuration
            ]
        ],
        'client' => [
            'default' => [],
            'asterisk2 => []
        ]
    ]
]
```

You can retrieve clients with service names:

- `pami.client.default`
- `pami.client.asterisk2`

### Multiple clients sharing the same connection

[](#multiple-clients-sharing-the-same-connection)

You can create another client with the same connection of another one:

```
return [
    'pami_module' => [
        'connection' => [
            'default' => [
                // configuration
            ]
        ],
        'client' => [
            'default' => [
                'connection' => 'default'
            ],
            'client2' => [
                'connection' => 'default'
            ]
        ]
    ]
]
```

```
$client1 = $serviceLocator->get('pami.client.default');
$client2 = $serviceLocator->get('pami.client.client2');

$client1->getConnection() === $client2->getConnection(); // true
```

Getting the original PAMI client
--------------------------------

[](#getting-the-original-pami-client)

You can retrieve the original PAMI client in two ways:

From service locator:

```
use PAMI\Client\Impl\ClientImpl;

/* @var ClientImpl $connection */
$connection = $serviceLocator->get('pami.connection.default');
```

From the `PamiModule` client:

```
use PamiModule\Service\Client;
use PAMI\Client\Impl\ClientImpl;

// Getting the PamiModule client
/* @var Client $client */
$client = $serviceLocator->get('pami.client.default');
// Getting the PAMI client
/* @var ClientImpl $connection */
$connection = $client->getConnection();
```

Available Listeners
-------------------

[](#available-listeners)

There are listeners ready to be used.

- `PamiModule\Listener\ConnectionStatusListener`
- `PamiModule\Listener\CacheListener`

### ConnectionStatusListener

[](#connectionstatuslistener)

This listener takes care to maintain a connection status, and to call `connect()` method when is required.
It can be useful when you share the client between some services, because you don't need to call `connect()` methods without to know the connection status. You can call directly `process()` and `sendAction()` methods and it will automatically calls `connect()` if a connection is not already opened.
You can also use `connect()` and `disconnect()` methods at any point of your application, the listener takes care to open or close connection only if is really necessary.
In order to use this listener, you can't use the connection (the original `PAMI` client) directly, because the connection status is maintained listening the `PamiModule` client events.

If you want to use the listener in multiple clients, you need to attach a new instance of it for every client.

You have to attach it to the client before to call any methods, so the best way is to use a delegator factory. This library provide a ready to use delegator factory:

```
return [
    'service_manager' => [
        'delegators' => [
            'pami.client.default' => [
                'PamiModule\\Service\\ConnectionStatusDelegatorFactory'
            ]
        ]
    ]
];
```

Note: if you share some connection between clients, you must attach the same listener to the clients, so you need to create your custom DelegatorFactory.

### CacheListener

[](#cachelistener)

You can use the CacheListener to cache results of some actions. The constructor require a cache storage instance and the action names that listener can cache response.

```
use PamiModule\Listener\CacheListener;
use Zend\Cache\Storage\StorageInterface;

$client = $serviceLocator->get('pami.client.default')
/* @var StorageInterface $cache */
$cache = $serviceLocator->get('asterisk_sippeers_cache');

$actionsToCache = ['SIPPeers', 'ShowPeer'];
$cacheListener = new CacheListener($cache, $actionsToCache);

$client->getEventManager()->attachAggregate($cacheListener);
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

Recently: every ~334 days

Total

15

Last Release

2120d ago

Major Versions

0.5.4 → 1.0.0-alpha12020-06-19

PHP version history (4 changes)0.1.0PHP &gt;=5.4

0.4.0PHP &gt;=5.6

0.5.0PHP ^5.6 || ^7.0

1.0.0-alpha1PHP ^7.4

### Community

Maintainers

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

---

Top Contributors

[![thomasvargiu](https://avatars.githubusercontent.com/u/732012?v=4)](https://github.com/thomasvargiu "thomasvargiu (48 commits)")

---

Tags

zf2Zend FrameworkasteriskpamiamiAsterisk Manager Interface

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/thomasvargiu-pami-module/health.svg)

```
[![Health](https://phpackages.com/badges/thomasvargiu-pami-module/health.svg)](https://phpackages.com/packages/thomasvargiu-pami-module)
```

###  Alternatives

[zfr/zfr-cors

Zend Framework module that let you deal with CORS requests

611.2M3](/packages/zfr-zfr-cors)[socalnick/scn-social-auth

Uses the HybridAuth PHP library to Enable authentication via Google, Facebook, Twitter, Yahoo!, etc for the ZfcUser ZF2 module.

21974.2k3](/packages/socalnick-scn-social-auth)[zf-commons/zfc-base

A set of genetic (abstract) classes which are commonly used across multiple modules.

1441.1M25](/packages/zf-commons-zfc-base)[snapshotpl/zf-snap-php-debug-bar

PHP Debug Bar module for Zend Framework 2

3026.1k](/packages/snapshotpl-zf-snap-php-debug-bar)[zfr/zfr-rest

Zend Framework 2 REST Module.

8120.6k](/packages/zfr-zfr-rest)[davidhavl/dherrorlogging

Full featured error logging module for ZF2/ZF3 application

1924.5k](/packages/davidhavl-dherrorlogging)

PHPackages © 2026

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