PHPackages                             signalwire/signalwire - 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. signalwire/signalwire

Abandoned → [signalwire-community/signalwire](/?search=signalwire-community%2Fsignalwire)Library[API Development](/categories/api)

signalwire/signalwire
=====================

Client library for connecting to SignalWire.

v2.3.10(4y ago)19100.2k↓84.3%2[1 issues](https://github.com/signalwire/signalwire-php/issues)MITPHPPHP ^7CI passing

Since Sep 21Pushed 1mo agoCompare

[ Source](https://github.com/signalwire/signalwire-php)[ Packagist](https://packagist.org/packages/signalwire/signalwire)[ Docs](https://github.com/signalwire/signalwire-php)[ RSS](/packages/signalwire-signalwire/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (1)Dependencies (8)Versions (28)Used By (0)

 [ ![](https://github.com/user-attachments/assets/0c8ed3b9-8c50-4dc6-9cc4-cc6cd137fd50) ](https://signalwire.com)SignalWire SDK for PHP
======================

[](#signalwire-sdk-for-php)

*Build AI voice agents, control live calls over WebSocket, and manage every SignalWire resource over REST -- all from one package.*

 [Documentation](https://developer.signalwire.com/sdks/agents-sdk) · [Report an Issue](https://github.com/signalwire/signalwire-docs/issues/new/choose) · [Packagist](https://packagist.org/packages/signalwire/sdk)

[![Discord](https://camo.githubusercontent.com/2ffbf481ab8850227f3daaf4ad21770a9d0a57ada33925ccb80d98b3654e4875/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973636f7264253230436f6d6d756e6974792d353836354632)](https://discord.com/invite/F2WNYTNjuF)[![MIT License](https://camo.githubusercontent.com/a56f9df3e8dbbf6d559c41181021800d218008aeae537b781b38830b7668e709/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d49542d4c6963656e73652d626c7565)](LICENSE)[![GitHub Stars](https://camo.githubusercontent.com/0a5793f2155b98ee142ab533c662764b07f828ebf58e547d8ebb50571f02155d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f7369676e616c776972652f7369676e616c776972652d706870)](https://github.com/signalwire/signalwire-php)

---

What's in this SDK
------------------

[](#whats-in-this-sdk)

CapabilityWhat it doesQuick link**AI Agents**Build voice agents that handle calls autonomously -- the platform runs the AI pipeline, your code defines the persona, tools, and call flow[Agent Guide](#ai-agents)**RELAY Client**Control live calls and SMS/MMS in real time over WebSocket -- answer, play, record, collect DTMF, conference, transfer, and more[RELAY docs](relay/README.md)**REST Client**Manage SignalWire resources over HTTP -- phone numbers, SIP endpoints, Fabric AI agents, video rooms, messaging, and 18+ API namespaces[REST docs](rest/README.md)```
composer require signalwire/sdk
```

---

AI Agents
---------

[](#ai-agents)

Each agent is a self-contained microservice that generates [SWML](docs/swml_service_guide.md) (SignalWire Markup Language) and handles [SWAIG](docs/swaig_reference.md) (SignalWire AI Gateway) tool calls. The SignalWire platform runs the entire AI pipeline (STT, LLM, TTS) -- your agent just defines the behavior.

```
require 'vendor/autoload.php';

use SignalWire\Agent\AgentBase;
use SignalWire\SWAIG\FunctionResult;

$agent = new AgentBase(name: 'my-agent', route: '/agent');

$agent->addLanguage(name: 'English', code: 'en-US', voice: 'inworld.Mark');
$agent->promptAddSection('Role', 'You are a helpful assistant.');

$agent->defineTool(
    name:        'get_time',
    description: 'Get the current time',
    parameters:  ['type' => 'object', 'properties' => []],
    handler: function (array $args, array $rawData): FunctionResult {
        return new FunctionResult('The time is ' . date('H:i:s'));
    },
);

$agent->run();
```

List an agent's SWAIG tools in-process, without running a server:

```
vendor/bin/swaig-test --file examples/simple_agent.php --list-tools
```

Dump its SWML or execute a tool against a running agent (`--url` mode):

```
vendor/bin/swaig-test --url http://user:pass@localhost:3000/simple --dump-swml
vendor/bin/swaig-test --url http://user:pass@localhost:3000/simple --exec get_time
```

### Agent Features

[](#agent-features)

- **Prompt Object Model (POM)** -- structured prompt composition via `promptAddSection()`
- **SWAIG tools** -- define functions with `defineTool()` that the AI calls mid-conversation, with native access to the call's media stack
- **Skills system** -- add capabilities with one-liners: `$agent->addSkill('datetime')`
- **Contexts and steps** -- structured multi-step workflows with navigation control
- **DataMap tools** -- tools that execute on SignalWire's servers, calling REST APIs without your own webhook
- **Dynamic configuration** -- per-request agent customization for multi-tenant deployments
- **Call flow control** -- pre-answer, post-answer, and post-AI verb insertion
- **Prefab agents** -- ready-to-use archetypes (InfoGatherer, Survey, FAQ, Receptionist, Concierge)
- **Multi-agent hosting** -- serve multiple agents on a single server with `AgentServer`
- **SIP routing** -- route SIP calls to agents based on usernames
- **Session state** -- persistent conversation state with global data and post-prompt summaries
- **Security** -- auto-generated basic auth, function-specific HMAC tokens, SSL support
- **Serverless** -- auto-detects CGI/FastCGI, AWS Lambda, Google Cloud Functions, and Azure Functions

### Agent Examples

[](#agent-examples)

The [`examples/`](examples/) directory contains working examples:

ExampleWhat it demonstrates[simple\_agent.php](examples/simple_agent.php)POM prompts, SWAIG tools, multilingual support, LLM tuning[contexts\_demo.php](examples/contexts_demo.php)Multi-persona workflow with context switching and step navigation[datamap\_demo.php](examples/datamap_demo.php)Server-side API tools without webhooks[skills\_demo.php](examples/skills_demo.php)Loading built-in skills (datetime, math)[call\_flow\_and\_actions\_demo.php](examples/call_flow_and_actions_demo.php)Call flow verbs, debug events, FunctionResult actions[session\_and\_state\_demo.php](examples/session_and_state_demo.php)on\_summary, global data, post-prompt summaries[multi\_agent\_server.php](examples/multi_agent_server.php)Multiple agents on one server[simple\_dynamic\_agent.php](examples/simple_dynamic_agent.php)Per-request dynamic configuration, multi-tenant routingSee [examples/README.md](examples/README.md) for the full list organized by category.

---

RELAY Client
------------

[](#relay-client)

Real-time call control and messaging over WebSocket. The RELAY client connects to SignalWire via the Blade protocol and gives you imperative, blocking control over live phone calls and SMS/MMS.

```
require 'vendor/autoload.php';

use SignalWire\Relay\Client;

$client = new Client([
    'project'  => $_ENV['SIGNALWIRE_PROJECT_ID'],
    'token'    => $_ENV['SIGNALWIRE_API_TOKEN'],
    'host'     => $_ENV['SIGNALWIRE_SPACE'] ?? 'relay.signalwire.com',
    'contexts' => ['default'],
]);

$client->onCall(function ($call) {
    $call->answer();
    $action = $call->play(media: [
        ['type' => 'tts', 'params' => ['text' => 'Welcome to SignalWire!']],
    ]);
    $action->wait();
    $call->hangup();
});

$client->connect();  // opens the WebSocket and authenticates
$client->run();
```

- 57+ calling methods (play, record, collect, detect, tap, stream, AI, conferencing, and more)
- SMS/MMS messaging with delivery tracking
- Action objects with `wait()`, `stop()`, `pause()`, `resume()`
- Auto-reconnect with exponential backoff

See the **[RELAY documentation](relay/README.md)** for the full guide, API reference, and examples.

---

REST Client
-----------

[](#rest-client)

Synchronous REST client for managing SignalWire resources and controlling calls over HTTP. No WebSocket required.

```
require 'vendor/autoload.php';

use SignalWire\REST\RestClient;

$client = new RestClient(
    project: $_ENV['SIGNALWIRE_PROJECT_ID'],
    token:   $_ENV['SIGNALWIRE_API_TOKEN'],
    host:    $_ENV['SIGNALWIRE_SPACE'],
);

$client->fabric()->aiAgents()->create(['name' => 'Support Bot', 'prompt' => ['text' => 'You are helpful.']]);
$client->calling()->play($callId, play: [['type' => 'tts', 'params' => ['text' => 'Hello!']]]);
$client->phoneNumbers()->search(['areacode' => '512']);
$client->datasphere()->documents()->search(queryString: 'billing policy');
```

- 22 namespaced API surfaces: Fabric (16 resource types), Calling (37 commands), Video, Datasphere, Phone Numbers, SIP, Queues, Recordings, and more
- Lightweight HTTP via cURL (one handle per request)
- Array returns -- raw data, no wrapper objects

See the **[REST documentation](rest/README.md)** for the full guide, API reference, and examples.

---

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

[](#installation)

```
composer require signalwire/sdk
```

Requires PHP 8.2+ with the `json`, `mbstring`, and `openssl` extensions.

Documentation
-------------

[](#documentation)

Full reference documentation is available at **[developer.signalwire.com/sdks/agents-sdk](https://developer.signalwire.com/sdks/agents-sdk)**.

Guides are also available in the [`docs/`](docs/) directory:

### Getting Started

[](#getting-started)

- [Agent Guide](docs/agent_guide.md) -- creating agents, prompt configuration, dynamic setup
- [Architecture](docs/architecture.md) -- SDK architecture and core concepts
- [SDK Features](docs/sdk_features.md) -- feature overview, SDK vs raw SWML comparison

### Core Features

[](#core-features)

- [SWAIG Reference](docs/swaig_reference.md) -- function results, actions, post\_data lifecycle
- [Contexts and Steps](docs/contexts_guide.md) -- structured workflows, navigation, gather mode
- [DataMap Guide](docs/datamap_guide.md) -- serverless API tools without webhooks
- [LLM Parameters](docs/llm_parameters.md) -- temperature, top\_p, barge confidence tuning
- [SWML Service Guide](docs/swml_service_guide.md) -- low-level construction of SWML documents

### Skills and Extensions

[](#skills-and-extensions)

- [Skills System](docs/skills_system.md) -- built-in skills and the modular framework
- [Third-Party Skills](docs/third_party_skills.md) -- creating and publishing custom skills

### Deployment

[](#deployment)

- [CLI Guide](docs/cli_guide.md) -- `swaig-test` command reference
- [Cloud Functions](docs/cloud_functions_guide.md) -- Lambda, Google Cloud Functions, Azure deployment
- [Configuration](docs/configuration.md) -- environment variables, SSL, proxy setup
- [Security](docs/security.md) -- authentication and security model

### Reference

[](#reference)

- [API Reference](docs/api_reference.md) -- complete class and method reference
- [Web Service](docs/web_service.md) -- HTTP server and endpoint details
- [Skills Parameter Schema](docs/skills_parameter_schema.md) -- skill parameter definitions

Environment Variables
---------------------

[](#environment-variables)

Get your project id, API token, and space hostname from the [SignalWire dashboard](https://signalwire.com/signin) (API → Credentials). Copy [`.env.example`](.env.example) to `.env` for the full list of variables the SDK reads; see [docs/configuration.md](docs/configuration.md) for the complete reference (custom CA bundles, RELAY overrides, and more).

VariableUsed byDescription`SIGNALWIRE_PROJECT_ID`RELAY, RESTProject identifier`SIGNALWIRE_API_TOKEN`RELAY, RESTAPI token`SIGNALWIRE_SPACE`RELAY, RESTSpace hostname (e.g. `example.signalwire.com`)`SWML_BASIC_AUTH_USER`AgentsBasic auth username (default: auto-generated)`SWML_BASIC_AUTH_PASSWORD`AgentsBasic auth password (default: auto-generated)`SWML_PROXY_URL_BASE`AgentsBase URL when behind a reverse proxy`SWML_SSL_ENABLED`AgentsEnable HTTPS (`true`, `1`, `yes`)`SWML_SSL_CERT_PATH`AgentsPath to SSL certificate`SWML_SSL_KEY_PATH`AgentsPath to SSL private key`SIGNALWIRE_LOG_LEVEL`AllLogging level (`debug`, `info`, `warn`, `error`)`SIGNALWIRE_LOG_MODE`AllSet to `off` to suppress all loggingTesting, Formatting, and Linting
--------------------------------

[](#testing-formatting-and-linting)

Test / format / lint go through the canonical `scripts/run-*.sh` entry points. They self-bootstrap their tool environment (put `vendor/bin` on `PATH`, `composer install` if `vendor/` is missing) and run correctly from **any**directory, so you never have to invoke the raw tools by hand. `scripts/run-ci.sh`calls these same scripts, so local behavior matches CI.

```
# Run the full test suite (canonical entry point; self-bootstraps, any CWD)
bash scripts/run-tests.sh

# Run a subset — pass a filter (phpunit --filter): a test name / class / regex
bash scripts/run-tests.sh LoggerTest

# Format (php-cs-fixer): APPLY in place (default) / --check = verify-only (CI)
bash scripts/run-format.sh
bash scripts/run-format.sh --check

# Lint (phpstan level 9, zero findings)
bash scripts/run-lint.sh

# Coverage (requires Xdebug or PCOV)
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html coverage/
```

License
-------

[](#license)

MIT -- see [LICENSE](LICENSE) for details.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance58

Moderate activity, may be stable

Popularity34

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~156 days

Total

24

Last Release

1679d ago

Major Versions

1.4.1 → v2.0.0-RC12019-07-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/299ee3456c29837bc7dabfa4cc01d25ab9c7ca90228d2b1c6b41a6c13f853604?d=identicon)[signalwire-community](/maintainers/signalwire-community)

---

Top Contributors

[![anthmFS](https://avatars.githubusercontent.com/u/524949?v=4)](https://github.com/anthmFS "anthmFS (77 commits)")[![edolix](https://avatars.githubusercontent.com/u/1760651?v=4)](https://github.com/edolix "edolix (67 commits)")[![mjerris](https://avatars.githubusercontent.com/u/227111?v=4)](https://github.com/mjerris "mjerris (18 commits)")[![lpradovera](https://avatars.githubusercontent.com/u/240074?v=4)](https://github.com/lpradovera "lpradovera (7 commits)")[![bryanrite](https://avatars.githubusercontent.com/u/829668?v=4)](https://github.com/bryanrite "bryanrite (6 commits)")[![danieleds](https://avatars.githubusercontent.com/u/402652?v=4)](https://github.com/danieleds "danieleds (6 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (4 commits)")[![natural411](https://avatars.githubusercontent.com/u/59837703?v=4)](https://github.com/natural411 "natural411 (2 commits)")[![briankwest](https://avatars.githubusercontent.com/u/1474890?v=4)](https://github.com/briankwest "briankwest (2 commits)")[![emcgee](https://avatars.githubusercontent.com/u/838618?v=4)](https://github.com/emcgee "emcgee (1 commits)")[![hey-august](https://avatars.githubusercontent.com/u/112662403?v=4)](https://github.com/hey-august "hey-august (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![marclaporte](https://avatars.githubusercontent.com/u/1004261?v=4)](https://github.com/marclaporte "marclaporte (1 commits)")[![iAmmar7](https://avatars.githubusercontent.com/u/35497934?v=4)](https://github.com/iAmmar7 "iAmmar7 (1 commits)")

---

Tags

apivideosmsiotvoicemmsRelayivrvoipfaxfreeswitchsignalwirelamlvoicemail

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/signalwire-signalwire/health.svg)

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

###  Alternatives

[signalwire-community/signalwire

Client library for connecting to SignalWire.

23154.9k](/packages/signalwire-community-signalwire)[laravel/framework

The Laravel Framework.

34.9k556.2M21.5k](/packages/laravel-framework)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

36826.2k2](/packages/telnyx-telnyx-php)[google/cloud

Google Cloud Client Library

1.2k16.9M57](/packages/google-cloud)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M672](/packages/shopware-core)

PHPackages © 2026

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