PHPackages                             salesrender/plugin-core-pbx - 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. salesrender/plugin-core-pbx

ActiveLibrary

salesrender/plugin-core-pbx
===========================

SalesRender plugin pbx core

0.4.4(8mo ago)0172proprietaryPHPPHP ^7.4.0

Since Jul 19Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/SalesRender/plugin-core-pbx)[ Packagist](https://packagist.org/packages/salesrender/plugin-core-pbx)[ RSS](/packages/salesrender-plugin-core-pbx/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (3)Versions (19)Used By (0)

Plugin Core PBX
===============

[](#plugin-core-pbx)

> Core framework for SalesRender PBX (telephony) plugins

[Russian version / Русская версия](readme.ru.md)

Overview
--------

[](#overview)

`salesrender/plugin-core-pbx` is a specialized core library that extends `salesrender/plugin-core` to provide the infrastructure for PBX (Private Branch Exchange) telephony plugins in the SalesRender ecosystem.

PBX plugins integrate SalesRender with VoIP/SIP telephony providers, enabling:

- **CDR (Call Detail Records)** -- parsing call records from external telephony APIs or webhooks and forwarding them to the SalesRender backend
- **Config provisioning** -- building and sending SIP gateway configuration (credentials, routing rules, protocol settings) to SalesRender
- **Call initiation via webhook** -- triggering outbound calls through special requests from the SalesRender platform

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

[](#installation)

```
composer require salesrender/plugin-core-pbx
```

### Requirements

[](#requirements)

- PHP &gt;= 7.4
- ext-json
- `salesrender/plugin-core` ^0.4.0
- `moneyphp/money` ^3.3
- `salesrender/plugin-component-purpose` ^2.0

Architecture
------------

[](#architecture)

### How It Extends plugin-core

[](#how-it-extends-plugin-core)

`plugin-core-pbx` extends the base `plugin-core` framework by providing two specialized factories:

1. **WebAppFactory** (`SalesRender\Plugin\Core\PBX\Factories\WebAppFactory`) extends the base `WebAppFactory` and automatically:

    - Registers all webhook parsers from `CdrParserContainer` as HTTP routes (each `CdrWebhookParserInterface` defines its own method and URL pattern)
    - Registers the optional `CallByWebhookAction` as a special request action for initiating calls
    - Adds CORS support
2. **ConsoleAppFactory** (`SalesRender\Plugin\Core\PBX\Factories\ConsoleAppFactory`) extends the base console factory, inheriting all standard CLI commands.

### What the Developer Must Implement

[](#what-the-developer-must-implement)

Interface / ClassPurpose`CdrApiParserInterface`Parse CDR records by polling the telephony provider API`CdrWebhookParserInterface`Parse CDR records received via webhook from the provider`ConfigBuilder`Build SIP gateway configuration from plugin settings`CallByWebhookAction` (optional)Handle call initiation requests from SalesRender### Bootstrap Configuration Steps

[](#bootstrap-configuration-steps)

The `bootstrap.php` file wires everything together (see `bootstrap.example.php` in the repository):

1. Configure the database connection (`Connector::config`)
2. Set the default language (`Translator::config`)
3. Configure plugin info (`Info::config` with `PluginType::PBX`)
4. Configure the settings form (`Settings::setForm`)
5. Configure autocompletes (optional)
6. Set up `ConfigBuilder` + `ConfigSender` as a settings save handler
7. Define CDR reward pricing function (`CdrPricing::config`)
8. Register CDR parsers (`CdrParserContainer::config`)
9. Register `CallByWebhookAction` (optional, for PBX Webhook plugin type)

Getting Started: Creating a PBX Plugin
--------------------------------------

[](#getting-started-creating-a-pbx-plugin)

### Step 1: Project Setup

[](#step-1-project-setup)

Create `composer.json`:

```
{
  "name": "your-vendor/plugin-pbx-your-provider",
  "type": "project",
  "autoload": {
    "psr-4": {
      "YourVendor\\Plugin\\PBX\\YourProvider\\": "src/"
    }
  },
  "require": {
    "php": "^7.4.0",
    "ext-json": "*",
    "salesrender/plugin-core-pbx": "^0.4.0"
  }
}
```

```
composer install
```

Create the directory structure:

```
your-plugin/
  bootstrap.php
  console.php
  public/
    index.php
  src/
    ConfigBuilder.php
    Forms/
      SettingsForm.php
    Parsers/
      CdrApiParser.php
      CdrWebhookParser.php
  db/
  .env

```

### Step 2: Bootstrap Configuration

[](#step-2-bootstrap-configuration)

Create `bootstrap.php` to wire all containers and configuration:

```
