PHPackages                             switcher-io/switcher-php - 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. switcher-io/switcher-php

ActiveLibrary

switcher-io/switcher-php
========================

PHP wrapper for switcher.io API

2.1(6y ago)02.4kMITPHPPHP &gt;=5.5.0

Since Aug 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/switcher-io/switcher-php)[ Packagist](https://packagist.org/packages/switcher-io/switcher-php)[ RSS](/packages/switcher-io-switcher-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

PHP Client for Switcher.io
==========================

[](#php-client-for-switcherio)

[![Build Status](https://camo.githubusercontent.com/96ad9461363cc30c077117b2fdfe03d746e6373cb9237ea1fa642dca4b8ba92f/68747470733a2f2f7472617669732d63692e6f72672f73776974636865722d696f2f73776974636865722d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/switcher-io/switcher-php)

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

[](#installation)

Using [composer](https://packagist.org/packages/switcher-io/switcher-php):

```
$ composer require switcher-io/switcher-php
```

Dead Man Switch example
-----------------------

[](#dead-man-switch-example)

```
$urlId = 'url identifier of the switch, e.g. "abc123" in https://dmsr.io/abc123.';
$key = 'switch key';

//initialize the api
$sw = new \SwitcherIO\DeadManSwitch($urlId, $key);

//call the /start endpoint to signal your job started (optional - only used if your switch has a max run time set)
$sw->start();

//your job code goes here

//call /complete to notifiy Switcher.io the job has finished
$sw->complete();

//you can also pause the switch
$sw->pause();
```

Error handling
==============

[](#error-handling)

A `\SwitcherIO\SwitcherException` will be thrown if an error occurs, or if Switcher.io does respond that the call is ok. `SwitcherException` has a `getStatusCode` method that you should use to determine why an exception was thrown. The status code will match a constant of `\SwitcherIO\DeadManSwitch`.

**Make sure to use error handling!** If you don't, a call to `$sw->start()` could prevent your job from finishing.

```
use \SwitcherIO\DeadManSwitch;

$sw = new DeadManSwitch('url id', 'key');

try {
    $sw->start();
} catch (\SwitcherIO\SwitcherException $e) {

    if ($e->getStatusCode() === DeadManSwitch::STATUS_ERROR_404) {
        //oops, you either got the url id or key wrong...
    } else if ($e->getStatusCode() === DeadManSwitch::STATUS_ERROR_START_BEFORE_COMPLETE) {
        /*
         * You get this error if your switch is using a max runtime, and for some reason your job
         * starts a new run before the last run finished. If this is a problem for you, handle it here...
         */
    }

}
```

Dev environments
----------------

[](#dev-environments)

You probably don't want your local dev environment to ping a real switch. To make the library do dummy pings in a local or dev environment, set the url id to 'test' or 'test-error':

```
//in this case complete() act as if it ran succesfully, and will not actually ping a switcher.io url
$sw = new \SwitcherIO\DeadManSwitch('test', 'key-does-not-matter-for-test-url');
$sw->complete();

/*
 * In this case complete() will throw a \SwitcherIO\SwitcherException with a status code
 * of \SwitcherIO\DeadManSwitch::STATUS_TEST_ERROR
 */
$sw = new \SwitcherIO\DeadManSwitch('test-error', 'key-does-not-matter-for-test-url');
$sw->complete();
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~40 days

Recently: every ~58 days

Total

7

Last Release

2211d ago

Major Versions

1.2 → 2.02020-04-07

PHP version history (2 changes)1.0PHP &gt;=5.3.0

1.1.1PHP &gt;=5.5.0

### Community

Maintainers

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

---

Top Contributors

[![jasvrcek](https://avatars.githubusercontent.com/u/953133?v=4)](https://github.com/jasvrcek "jasvrcek (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/switcher-io-switcher-php/health.svg)

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

PHPackages © 2026

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