PHPackages                             pabloader/authy-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. pabloader/authy-php

Abandoned → [authy/php](/?search=authy%2Fphp)Library[Authentication &amp; Authorization](/categories/authentication)

pabloader/authy-php
===================

PHP client for Authy

v2.5(9y ago)08.2k1MITPHPPHP &gt;=5.3.0

Since Aug 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Pabloader/authy-php)[ Packagist](https://packagist.org/packages/pabloader/authy-php)[ Docs](https://github.com/authy/authy-php)[ RSS](/packages/pabloader-authy-php/feed)WikiDiscussions master Synced 2d ago

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

PHP Client for Authy API
========================

[](#php-client-for-authy-api)

A php library for using the Authy API.

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

[](#installation)

This library requires PHP 5.3+

### Install via composer:

[](#install-via-composer)

[`pabloader/authy-php`](http://packagist.org/pabloader/authy-php) package is available on [Packagist](http://packagist.org).

Include it in your `composer.json` as follows:

```
{
    "require": {
        "authy/php": "2.*"
    }
}

```

Usage
-----

[](#usage)

To use this client you just need to use Authy\_Api and initialize it with your API KEY

```
$authy_api = new Authy\AuthyApi('#your_api_key');

```

Now that you have an Authy API object you can start sending requests.

NOTE: if you want to make requests to sandbox you have to pass the sandbox url as the second argument:

```
$authy_api = new Authy\AuthyApi('#your_api_key', 'http://sandbox-api.authy.com');

```

Creating Users
--------------

[](#creating-users)

**NOTE: User is matched based on cellphone and country code not e-mail. A cellphone is uniquely associated with an authy\_id.**

Creating users is very easy, you need to pass an email, a cellphone and *optionally* a country code:

```
$user = $authy_api->registerUser('new_user@email.com', '405-342-5699', 1); //email, cellphone, country_code

```

in this case `1` is the country code (USA). If no country code is specified, it defaults to USA.

You can easily see if the user was created by calling `ok()`. If request went right, you need to store the authy id in your database. Use `user->id()` to get this `id` in your database.

```
if($user->ok())
    // store user->id() in your user database

```

if something goes wrong `ok()` returns `false` and you can see the errors using the following code

```
else
    foreach($user->errors() as $field => $message) {
      printf("$field = $message");
    }

```

it returns a dictionary explaining what went wrong with the request. Errors will be in plain English and can be passed back to the user.

Verifying Tokens
----------------

[](#verifying-tokens)

**NOTE: Token verification is only enforced if the user has completed registration. To change this behaviour see Forcing Verification section below.**

> *Registration is completed once the user installs and registers the Authy mobile app or logins once successfully using SMS.*

To verify tokens you need the user id and the token. The token you get from the user through your login form.

```
$verification = $authy_api->verifyToken('authy-id', 'token-entered-by-the-user');

```

Once again you can use `ok()` to verify whether the token was valid or not.

```
if($verification->ok())
    // the user is valid

```

#### Forcing Verification

[](#forcing-verification)

If you wish to verify tokens even if the user has not yet complete registration, pass force=true when verifying the token.

```
$verification = $authy_api->verifyToken('authy-id', 'token-entered-by-the-user', array("force" => "true"));

```

Requesting SMS Tokens
---------------------

[](#requesting-sms-tokens)

To be able to use this method you need to have activated the SMS plugin for your Authy App.

To request a SMS token you only need the user id.

```
$sms = $authy_api->requestSms('authy-id');

```

As always, you can use `ok()` to verify if the token was sent. This call will be ignored if the user is using the Authy Mobile App. If you still want to send the SMS pass `force=>true` as an option

```
$sms = $authy_api->requestSms('authy-id', array("force" => "true"));

```

Checking User Status
--------------------

[](#checking-user-status)

To check a user status, just pass the user id.

```
$status = $authy_api->userStatus('authy_id');

```

Phone Verification &amp;&amp; Info
----------------------------------

[](#phone-verification--info)

Authy has an API to verify users via phone calls or sms. Also, user phone information can be gethered for support and verification purposes.

### Phone Verification Start

[](#phone-verification-start)

In order to start a phone verification, we ask the API to send a token to the user via sms or call:

```
$authy_api->phoneVerificationStart('111-111-1111', '1', 'sms');

```

Optionally you can specify the language that you prefer the phone verification message to be sent. Supported languages include: English (`en`), Spanish (`es`), Portuguese (`pt`), German (`de`), French (`fr`) and Italian (`it`). If not specified, English will be used.

```
$authy_api->phoneVerificationStart('111-111-1111', '1', 'sms', 'es');
// This will send a message in spanish

```

### Phone Verification Check

[](#phone-verification-check)

Once you get the verification from user, you can check if it's valid with:

```
$authy_api->phoneVerificationCheck('111-111-1111', '1', '0000');

```

### Phone Info

[](#phone-info)

If you want to gather additional information about user phone, use phones info.

```
$authy_api->phoneInfo('111-111-1111', '1');

```

Tests
-----

[](#tests)

You will need to install composer `https://getcomposer.org/download/`and install dependencies with `composer install --no-dev`. Also You will need to install phpunit `https://phpunit.de/manual/current/en/installation.html`

Then you can run test by executing this command `make`

### More…

[](#more)

You can find the full API documentation in the [official documentation](https://docs.authy.com) page.

Copyright
---------

[](#copyright)

Copyright (c) 2011-2020 Authy Inc.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 60.4% 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 ~159 days

Recently: every ~199 days

Total

6

Last Release

3541d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1898032?v=4)[Pavel](/maintainers/Pabloader)[@Pabloader](https://github.com/Pabloader)

---

Top Contributors

[![dcu](https://avatars.githubusercontent.com/u/73729?v=4)](https://github.com/dcu "dcu (29 commits)")[![serargz](https://avatars.githubusercontent.com/u/2054553?v=4)](https://github.com/serargz "serargz (6 commits)")[![vargasx](https://avatars.githubusercontent.com/u/15661037?v=4)](https://github.com/vargasx "vargasx (3 commits)")[![senekis](https://avatars.githubusercontent.com/u/189874?v=4)](https://github.com/senekis "senekis (2 commits)")[![GiamPy5](https://avatars.githubusercontent.com/u/4460702?v=4)](https://github.com/GiamPy5 "GiamPy5 (2 commits)")[![castis](https://avatars.githubusercontent.com/u/67277?v=4)](https://github.com/castis "castis (1 commits)")[![zQueal](https://avatars.githubusercontent.com/u/239193?v=4)](https://github.com/zQueal "zQueal (1 commits)")[![cmodijk](https://avatars.githubusercontent.com/u/771041?v=4)](https://github.com/cmodijk "cmodijk (1 commits)")[![enygma](https://avatars.githubusercontent.com/u/66796?v=4)](https://github.com/enygma "enygma (1 commits)")[![rotorsolutions](https://avatars.githubusercontent.com/u/9609046?v=4)](https://github.com/rotorsolutions "rotorsolutions (1 commits)")[![tufla](https://avatars.githubusercontent.com/u/996559?v=4)](https://github.com/tufla "tufla (1 commits)")

---

Tags

apiAuthenticationtwo-factor

### Embed Badge

![Health badge](/badges/pabloader-authy-php/health.svg)

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

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k294.2M215](/packages/google-auth)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)[srmklive/authy

Plugin for enabling two-factor authentication in Laravel applications

6841.3k](/packages/srmklive-authy)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)[descope/descope-php

Descope SDK for PHP

4223.8k](/packages/descope-descope-php)

PHPackages © 2026

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