Download the PHP package salesrender/plugin-core-pbx without Composer

On this page you can find all versions of the php package salesrender/plugin-core-pbx. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package plugin-core-pbx

Plugin Core PBX

Core framework for SalesRender PBX (telephony) plugins

Russian version / Русская версия

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:

Installation

Requirements

Architecture

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

Interface / Class Purpose
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

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

Step 1: Project Setup

Create composer.json:

Create the directory structure:

Step 2: Bootstrap Configuration

Create bootstrap.php to wire all containers and configuration:

Step 3: Implement Required Interfaces

3a. ConfigBuilder

Build the SIP gateway Config object from plugin settings:

3b. CdrApiParserInterface

Implement CDR polling from the telephony provider API. The __invoke() method must return an array of CDR objects:

3c. CdrWebhookParserInterface

Handle incoming CDR data via webhook. This also acts as a Slim route handler. The httpMethod() and getPattern() methods define how the route is registered:

Step 4: Web & Console Entry Points

public/index.php (HTTP entry point):

console.php (CLI entry point):

Step 5: .env Configuration

Create a .env file in the project root:

Variable Description
LV_PLUGIN_PBX_PRICING_CURRENCY Currency code for call pricing (e.g. RUB, USD)
LV_PLUGIN_PBX_PRICING_PBX PBX encryption pricing flag
LV_PLUGIN_PBX_PRICING_RECORD Call recording pricing flag
LV_PLUGIN_PBX_PRICING_REWARD Reward percentage for CDR pricing calculation

Step 6: Deploy

Deploy the plugin as a standard SalesRender plugin:

  1. Point the web server document root to public/
  2. Ensure the db/ directory is writable for SQLite storage
  3. Configure the .env file with production values
  4. Set up a cron job to run php console.php cron every minute

HTTP Routes

Inherited from plugin-core

Method Path Description
POST /protected/info Plugin information
POST /protected/settings Get/save settings
POST /protected/registration Plugin registration

CDR Webhook Routes

Dynamically registered based on CdrWebhookParserInterface implementations. Each parser defines its own HTTP method and URL pattern via httpMethod() and getPattern().

For example, a parser returning 'POST' and '/protected/cdr-webhook' will register a POST /protected/cdr-webhook route.

Multiple webhook parsers can be registered at once (they are passed as variadic arguments to CdrParserContainer::config()).

Special Request Routes (Optional)

If CallByWebhookAction is configured via CallByWebhookContainer::config(), the core registers:

Method Path Description
POST /protected/special-request/call Initiate a call via webhook from the SalesRender backend

CLI Commands

The PBX console factory inherits all base commands from plugin-core:

Command Description
cron Run scheduled cron tasks
special-request:send Process queued special requests
db:migrate Run database migrations

Key Classes & Interfaces

CDR (Call Detail Record)

CDR

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\CDR

The base call record model. Implements JsonSerializable.

Property Type Description
$phone string Phone number (required, set in constructor)
$callId ?string Unique call identifier
$timestamp int Unix timestamp of the call
$duration int Call duration in seconds
$recordUri ?string URL to the call recording file
$pricing ?CdrPricing Call pricing information

CdrPricing

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\CdrPricing

Handles call cost calculation with provider pricing and reward markup. Uses moneyphp/money for monetary values. Implements JsonSerializable.

Method Returns Description
__construct(Money $providerPricing) -- Set the provider's cost for the call
getProviderPricing() Money Get the provider cost
getRewardPricing() Money Get the calculated reward (uses the callable set via config())
static config(callable $rewardCalc) void Set the reward calculation function fn(Money): Money

JSON output includes both provider and reward pricing objects.

CdrTiming

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\Components\CdrTiming

Detailed call timing information.

Property Type Description
$start int Call start time (unix timestamp)
$duration int Total call duration in seconds
$earlyMediaDuration int Early media (ringing) duration in seconds

Direction

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\Components\Direction

Call direction enum. Extends EnumHelper.

Constant Value
Direction::INCOMING 'incoming'
Direction::OUTGOING 'outgoing'

Reference

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\Components\Reference

Identifies a call party (caller, callee, or plugin). Implements JsonSerializable.

Property Type Description
$alias string Human-readable alias
$id string Unique identifier

SipCause

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\Components\SipCause

SIP response code with human-readable phrase.

Property Type Description
$code int SIP status code (e.g. 200, 486, 503)
$phrase string Status phrase (e.g. "OK", "Busy Here")

CDR Webhook

CdrWebhook

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\Webhook\CdrWebhook

Extended CDR model for webhook-based call records. Extends CDR with additional SIP-specific fields.

Property Type Description
$timing CdrTiming Detailed timing information
$direction Direction Call direction (incoming/outgoing)
$sipCause SipCause SIP failure cause
$hangupCause SipCause Hangup cause
$caller Reference Caller reference
$callee Reference Callee reference
$plugin Reference Plugin reference

JSON serialization includes all timing, SIP, and party fields.

CdrWebhookSender

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\Webhook\CdrWebhookSender

Sends CdrWebhook records to the SalesRender backend via special request (HTTP PUT to /CRM/plugin/pbx/cdr).

Parser Interfaces & Container

CdrApiParserInterface

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\CdrApiParserInterface

Method Returns Description
__invoke() CDR[] Fetch and parse CDR records from the provider API

CdrWebhookParserInterface

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\CdrWebhookParserInterface

Method Returns Description
httpMethod() string HTTP method for the webhook route (e.g. 'POST', 'PUT')
getPattern() string URL pattern for the webhook route (e.g. '/protected/cdr-webhook')
__invoke(ServerRequest, Response, array) Response Handle the webhook request and return an HTTP response

CdrParserContainer

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\CdrParserContainer

Static container that holds CDR parser instances. Must be configured in bootstrap.php.

Method Description
static config(?CdrApiParserInterface, CdrWebhookParserInterface ...) Register an API parser and zero or more webhook parsers
static getApiParser(): CdrApiParserInterface Get the registered API parser
static getWebhookParsers(): CdrWebhookParserInterface[] Get all registered webhook parsers

CDR Sender

CdrSender

Namespace: SalesRender\Plugin\Core\PBX\Components\CDR\CdrSender

Sends basic CDR records to SalesRender backend via special request (HTTP PATCH to /CRM/plugin/pbx/cdr). The CDR data is signed with a JWT token (24-hour TTL).

Config

Config

Namespace: SalesRender\Plugin\Core\PBX\Components\Config\Config

SIP gateway configuration model. Implements JsonSerializable. All properties are public and writable.

Property Type Default Description
$username string '' SIP account username
$password string '' SIP account password
$from string '' Outgoing caller number
$prefix string '' Dialing prefix
$protocol string 'udp' SIP transport protocol (udp or tcp)
$domain string '' SIP domain
$realm string '' SIP realm
$proxy string '' SIP proxy address
$header_for_DID string '' Header name where the provider passes the DID (A-number)
$expires int 600 Registration expiry time in seconds
$register bool false Whether SIP registration is required
$number_format_with_plus bool true Prepend + to phone numbers
$send_additional_data_via_x_headers bool false Send extra data in SIP X-headers
$record bool true Enable call recording
$map_phone_to_gateway bool false Map phone numbers to gateway
$originate_timeout int 60 Call originate timeout in seconds

JSON serialization also includes company_id, plugin_id, and plugin_alias from the current plugin reference.

ConfigBuilder

Namespace: SalesRender\Plugin\Core\PBX\Components\Config\ConfigBuilder

Interface that the plugin developer must implement to build a Config from current plugin Settings.

Method Returns Description
__construct(Settings $settings) -- Receive current plugin settings
__invoke() Config Build and return the Config object

ConfigSender

Namespace: SalesRender\Plugin\Core\PBX\Components\Config\ConfigSender

Sends the gateway configuration to the SalesRender backend via special request (HTTP PUT to /CRM/plugin/pbx/gateway). Typically used inside Settings::addOnSaveHandler().

Webhook (Call Initiation)

CallByWebhookAction

Namespace: SalesRender\Plugin\Core\PBX\Components\Webhook\CallByWebhookAction

Abstract class extending SpecialRequestAction. Implement this to handle call initiation requests from the SalesRender backend. The special request action name is 'call'.

Your implementation must override the handle() method to perform the actual call via the telephony provider API.

CallByWebhookContainer

Namespace: SalesRender\Plugin\Core\PBX\Components\Webhook\CallByWebhookContainer

Optional static container for the call-by-webhook action. If not configured, no call initiation route is registered.

Method Description
static config(?CallByWebhookAction) Register the action (pass null to disable)
static getCallByWebhookAction(): ?CallByWebhookAction Get the registered action or null

Special Requests

PBX plugins use special requests to communicate asynchronously with the SalesRender backend:

Sender Class HTTP Method Backend Endpoint TTL Description
CdrSender PATCH /CRM/plugin/pbx/cdr 24h Send basic CDR records
CdrWebhookSender PUT /CRM/plugin/pbx/cdr 24h Send extended webhook CDR records
ConfigSender PUT /CRM/plugin/pbx/gateway 24h Send SIP gateway configuration

All special requests are signed with a JWT token and queued as SpecialRequestTask entries in the database, then dispatched by the special-request:send CLI command.

Example Plugin

A complete working example is available at salesrender/plugin-pbx-example.

The example demonstrates:

Dependencies

Package Version Purpose
salesrender/plugin-core ^0.4.0 Base plugin framework
moneyphp/money ^3.3 Monetary value handling for CDR pricing
salesrender/plugin-component-purpose ^2.0 Plugin type and purpose definitions (PbxPluginClass, PluginEntity)

See Also


All versions of plugin-core-pbx with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
ext-json Version *
salesrender/plugin-core Version ^1.0
moneyphp/money Version ^4.0
salesrender/plugin-component-purpose Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package salesrender/plugin-core-pbx contains the following files

Loading the files please wait ...