PHPackages                             rtckit/sip - 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. rtckit/sip

ActiveLibrary

rtckit/sip
==========

SIP protocol implementation written in PHP

0.7.1(2y ago)4417.4k↓20.8%3[1 PRs](https://github.com/rtckit/php-sip/pulls)2MITPHPPHP &gt;=7.4.0CI passing

Since Oct 29Pushed 1y ago5 watchersCompare

[ Source](https://github.com/rtckit/php-sip)[ Packagist](https://packagist.org/packages/rtckit/sip)[ Docs](https://github.com/rtckit/php-sip)[ RSS](/packages/rtckit-sip/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (20)Used By (2)

[ ![php-sip](https://camo.githubusercontent.com/15b4dae53843b97161d9398eeb8077e5b29d344c9e9736cac39db9ec4a360cf8/68747470733a2f2f7261772e6769746875622e636f6d2f7274636b69742f6d656469612f6d61737465722f7068702d7369702f726561646d652d73706c6173682e706e67)](#php-sip-parsingrendering-library)PHP SIP Parsing/Rendering Library
=================================

[](#php-sip-parsingrendering-library)

[RFC 3261](https://tools.ietf.org/html/rfc3261) compliant SIP parsing and rendering library for PHP 7.4.

[![CI Status](https://github.com/rtckit/php-sip/workflows/CI/badge.svg)](https://github.com/rtckit/php-sip/actions/workflows/ci.yaml)[![Psalm Type Coverage](https://camo.githubusercontent.com/2c5258c898b1e53f2aef2587112ed0d0959f7cbec50fde0e7e0ba91f133e4f93/68747470733a2f2f73686570686572642e6465762f6769746875622f7274636b69742f7068702d7369702f636f7665726167652e737667)](https://shepherd.dev/github/rtckit/php-sip)[![Latest Stable Version](https://camo.githubusercontent.com/6ba11e641c6f0cafd5b62fcc848a967ce73a9cb728133c8013a411481d13820d/68747470733a2f2f706f7365722e707567782e6f72672f7274636b69742f7369702f762f737461626c652e706e67)](https://packagist.org/packages/rtckit/sip)[![Installs on Packagist](https://camo.githubusercontent.com/b1d251027481c7a3b4ca68cf517fcadf9ade403998d9460b78b7faf920814d01/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7274636b69742f7369703f636f6c6f723d626c7565266c6162656c3d496e7374616c6c732532306f6e2532305061636b6167697374)](https://packagist.org/packages/rtckit/sip)[![Test Coverage](https://camo.githubusercontent.com/4e7836059a15b34eae971259dad805f2df7333cec055f8a045a52c97882a32da/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f61666635656538653865663362353136383963322f746573745f636f766572616765)](https://codeclimate.com/github/rtckit/php-sip/test_coverage)[![Maintainability](https://camo.githubusercontent.com/79003d1c55c8cbb4a78ac8922d4450bcd3ce128249784dbf0c662130c19487d2/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f61666635656538653865663362353136383963322f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/rtckit/php-sip/maintainability)[![License](https://camo.githubusercontent.com/b8cadaa967891081f8f165695470689986c028821dd8a040132f6e661795dc0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c7565)](LICENSE)

Quickstart
----------

[](#quickstart)

#### SIP Message Parsing

[](#sip-message-parsing)

Once [installed](#installation), you can parse SIP messages right away as follows:

```
/*
 * $text holds your SIP message as a string, for example
 * $text = 'REGISTER sip:192.168.0.1 SIP/2.0 /.../';
 */
$message = \RTCKit\SIP\Message::parse($text);

/* Outputs "RTCKit\SIP\Request" */
echo get_class($message) . PHP_EOL;

/* Outputs something similar to:
 * Protocol version:   SIP/2.0
 * Request method:     REGISTER
 * Request URI:        sip:192.168.0.1
 * Via:                192.168.0.2:5050
 * Via branch:         z9hG4bK.eAV4o0nXr
 * From scheme:        sip
 * From user:          buzz
 * From host:          192.168.0.1
 * From tag:           SFJbQ2oWh
 * To scheme:          sip
 * To user:            buzz
 * To host:            192.168.0.1
 * Sequence number:    20
 * Call ID:            ob0EYyuyC0
 */
printf("Protocol version:   %s" . PHP_EOL, $message->version);
printf("Request method:     %s" . PHP_EOL, $message->method);
printf("Request URI:        %s" . PHP_EOL, $message->uri);
printf("Via:                %s" . PHP_EOL, $message->via->values[0]->host);
printf("Via branch:         %s" . PHP_EOL, $message->via->values[0]->branch);
printf("From scheme:        %s" . PHP_EOL, $request->from->uri->scheme);
printf("From user:          %s" . PHP_EOL, $request->from->uri->user);
printf("From host:          %s" . PHP_EOL, $request->from->uri->host);
printf("From tag:           %s" . PHP_EOL, $request->from->tag);
printf("To scheme:          %s" . PHP_EOL, $request->to->uri->scheme);
printf("To user:            %s" . PHP_EOL, $request->to->uri->user);
printf("To host:            %s" . PHP_EOL, $request->to->uri->host);
printf("Sequence number:    %s" . PHP_EOL, $message->cSeq->sequence);
printf("Call ID:            %s" . PHP_EOL, $message->callId->value);
```

#### SIP Message Rendering

[](#sip-message-rendering)

Rendering is the opposite action of parsing; for example, let's prepare a `200 OK` response for a `REGISTER` request:

```
$response = new \RTCKit\SIP\Response;
$response->version = 'SIP/2.0';
$response->code = 200;

$response->via = new \RTCKit\SIP\Header\ViaHeader;
$response->via->values[0] = new \RTCKit\SIP\Header\ViaValue;
$response->via->values[0]->protocol = 'SIP';
$response->via->values[0]->version = '2.0';
$response->via->values[0]->transport = 'UDP';
$response->via->values[0]->host = '192.168.0.2:5050';
$response->via->values[0]->branch = 'z9hG4bK.eAV4o0nXr';

$response->from = new \RTCKit\SIP\Header\NameAddrHeader;
$response->from->uri = new \RTCKit\SIP\URI;
$response->from->uri->scheme = 'sip';
$response->from->uri->user = 'buzz';
$response->from->uri->host = '192.168.0.1';
$response->from->tag = 'SFJbQ2oWh';

$response->to = new \RTCKit\SIP\Header\NameAddrHeader;
$response->to->uri = new \RTCKit\SIP\URI;
$response->to->uri->scheme = 'sip';
$response->to->uri->user = 'buzz';
$response->to->uri->host = '192.168.0.1';
$response->to->tag = '8cQtUyH6N5N9K';

$response->cSeq = new \RTCKit\SIP\Header\CSeqHeader;
$response->cSeq->sequence = 20;
$response->cSeq->method = 'REGISTER';

$response->callId = new \RTCKit\SIP\Header\CallIdHeader;
$response->callId->value = 'ob0EYyuyC0';

$response->maxForwards = new \RTCKit\SIP\Header\ScalarHeader;
$response->maxForwards->value = 70;

$response->contact = new \RTCKit\SIP\Header\ContactHeader;
$response->contact->values[0] = new \RTCKit\SIP\Header\ContactValue;
$response->contact->values[0]->uri = new \RTCKit\SIP\URI;
$response->contact->values[0]->uri->scheme = 'sip';
$response->contact->values[0]->uri->user = 'buzz';
$response->contact->values[0]->uri->host = '192.168.0.2';
$response->contact->values[0]->uri->port = 5050;
$response->contact->values[0]->uri->transport = 'udp';
$response->contact->values[0]->expires = 3600;

$response->userAgent = new \RTCKit\SIP\Header\Header;
$response->userAgent->values[0] = 'MyDeskPhone/1.0.0';

/* Outputs:
 * SIP/2.0 200 OK
 * Via: SIP/2.0/UDP 192.168.0.2:5050;branch=z9hG4bK.eAV4o0nXr
 * From: ;tag=SFJbQ2oWh
 * To: ;tag=8cQtUyH6N5N9K
 * Contact: ;expires=3600
 * Call-ID: ob0EYyuyC0
 * CSeq: 20 REGISTER
 * Max-Forwards: 70
 * User-Agent: MyDeskPhone/1.0.0
 */
echo $response->render();
```

#### SIP Message Stream Parsing

[](#sip-message-stream-parsing)

If your use case involves a continuous data stream rather than individual messages, the `StreamParser` class can help; this is particularly useful for analyzing SIP trace files or packet captures, parsing SIP traffic over TCP etc.

```
/* Instantiate the Stream Parser */
$parser = new \RTCKit\SIP\StreamParser;

$fp = fopen(/.../);

while (!feof($fp)) {
    $bytes = fread($fp, 256);

    /* The actual input string ($bytes) can be retrieved from any stream-like source */
    if ($parser->process($bytes, $messages) === \RTCKit\SIP\StreamParser::SUCCESS) {
        foreach ($messages as $message) {
            /*
             * $message is either a Request or a Response object, using
             * the same structure as messages returned by Message::parse()
             */
        }
    }
}
```

Lastly, the provided [examples](examples) are a good starting point.

Requirements
------------

[](#requirements)

**RTCKit\\SIP** is compatible with PHP 7.4+ and has no external library and extension dependencies.

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

[](#installation)

You can add the library as project dependency using [Composer](https://getcomposer.org/):

```
composer require rtckit/sip
```

If you only need the library during development, for instance when used in your test suite, then you should add it as a development-only dependency:

```
composer require --dev rtckit/sip
```

Tests
-----

[](#tests)

To run the test suite, clone this repository and then install dependencies via Composer:

```
composer install
```

Then, go to the project root and run:

```
php -d memory_limit=-1 ./vendor/bin/phpunit -c ./etc/phpunit.xml.dist
```

### Static Analysis

[](#static-analysis)

In order to ensure high code quality, **RTCKit\\SIP** uses [PHPStan](https://github.com/phpstan/phpstan) and [Psalm](https://github.com/vimeo/psalm):

```
php -d memory_limit=-1 ./vendor/bin/phpstan analyse -c ./etc/phpstan.neon -n -vvv --ansi --level=max src
php -d memory_limit=-1 ./vendor/bin/psalm --config=./etc/psalm.xml
```

License
-------

[](#license)

MIT, see [LICENSE file](LICENSE).

### Acknowledgments

[](#acknowledgments)

- [SIP Protocol Contributors/IETF Trust](https://www.ietf.org/standards/rfcs/)
- [PROTOS SIP Test Material](https://www.ee.oulu.fi/research/ouspg/PROTOS_Test-Suite_c07-sip) - Oulu University Secure Programming Group, Finland
- [lioneagle/sipparser Test Material](https://github.com/lioneagle/sipparser/blob/master/src/testdata/sip_msg.txt) (MIT license)

### Contributing

[](#contributing)

Bug reports (and small patches) can be submitted via the [issue tracker](https://github.com/rtckit/php-sip/issues). Forking the repository and submitting a Pull Request is preferred for substantial patches.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% 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 ~55 days

Recently: every ~149 days

Total

18

Last Release

1092d ago

### Community

Maintainers

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

---

Top Contributors

[![cdosoftei](https://avatars.githubusercontent.com/u/7636091?v=4)](https://github.com/cdosoftei "cdosoftei (57 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

composer-libraryphprfc-3261sipsip-parsertelcotelecommunicationstelephonyvoipvoip-libraryvoiptelephonysiptelcosession initiation protocolrfc 3261

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[marcelog/pami

Asterisk Manager Interface (AMI) client for PHP, event driven, object oriented

415750.6k1](/packages/marcelog-pami)[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.

35636.1k2](/packages/telnyx-telnyx-php)[mikopbx/core

Free PBX system for SMB based on Asterisk

5271.4k](/packages/mikopbx-core)[chan-sccp/pami

Asterisk Manager Interface (AMI) client for PHP, event driven, object oriented (Fork)

2952.3k](/packages/chan-sccp-pami)[wormling/phparia

Asterisk REST Interface (ARI) client for PHP.

419.8k](/packages/wormling-phparia)

PHPackages © 2026

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