Download the PHP package nextgenswitch/nextgenswitch-php without Composer

On this page you can find all versions of the php package nextgenswitch/nextgenswitch-php. 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 nextgenswitch-php

NextGenSwitch PHP SDK

Tests PHP

The official PHP SDK for the NextGenSwitch Programmable Voice API. Create and modify calls, build escaped Voice XML, stream call audio to AI services, and parse Gather and Dial callbacks with typed PHP objects.

Requirements

Installation

Configure the Client

Keep credentials in environment variables or a secret manager.

The SDK sends credentials with the X-Authorization and X-Authorization-Secret headers documented by NextGenSwitch. Use HTTPS for remote deployments.

Create a Call

Use either inline Voice XML or a URL that returns a valid <Response>.

To use a hosted XML document:

Exactly one of responseXml or responseUrl is required.

Modify an Active Call

Build Voice XML

Supported helpers match the official API documentation:

XML verb SDK method
<Say> say($text, $attributes)
<Play> play($url, $attributes)
<Gather> gather($attributes, $children)
<Dial> dial($to, $attributes, $children)
<Record> record($attributes)
<Connect><Stream> stream($url, $parameters, $attributes)
<Hangup> hangup()
<Pause> pause($seconds)
<Redirect> redirect($url, $method)
<Bridge> bridge($callId, $bridgeAfterEstablish)
<Leave> leave()

Text and attribute values are encoded through PHP's DOM implementation instead of string concatenation.

Stream Audio to an AI Service

Do not put provider API keys in Voice XML. Resolve secrets on the WebSocket service.

Parse Action Callbacks

Dial callbacks can be parsed with DialResult::fromArray($_POST). Its established, duration, waitingDuration, bridgeCallId, and recordFile properties correspond to the documented callback fields.

Callback authenticity controls are deployment-specific and are not currently documented as a NextGenSwitch signature scheme. Restrict callback endpoints, require TLS, validate expected fields, and apply your own authentication controls where supported.

Errors

Runnable Examples

After composer install, configure credentials without committing them:

Then run or adapt these examples:

Example Purpose
create-call.php Create a call with inline Gather instructions
modify-call.php Replace the flow of an active call by call ID
record-call.php Record caller audio with beep, transcription, trimming, and callback
dial-with-recording.php Dial an external destination and record from answer
stream-to-ai-agent.php Stream bidirectional audio to a WebSocket AI service
gather-webhook.php Parse Gather input and return the next Voice XML flow
dial-webhook.php Parse Dial completion and return follow-up Voice XML

For example:

Replace all example.com callback, media, and WebSocket URLs with TLS endpoints you control. Validate callback input and never commit API or SIP credentials.

Development

The test workflow covers PHP 8.1, 8.2, 8.3, and 8.4.

Documentation and Support

License

MIT


All versions of nextgenswitch-php with dependencies

PHP Build Version
Package Version
No informations.
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 nextgenswitch/nextgenswitch-php contains the following files

Loading the files please wait ...