PHPackages                             vasily-kartashov/amazon-alexa-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. [API Development](/categories/api)
4. /
5. vasily-kartashov/amazon-alexa-php

ActiveLibrary[API Development](/categories/api)

vasily-kartashov/amazon-alexa-php
=================================

Amazon Alexa interface for PHP

0.2.6(7y ago)412.7kMITPHPPHP &gt;=7.0

Since Aug 26Pushed 5y ago2 watchersCompare

[ Source](https://github.com/vasily-kartashov/amazon-alexa-php)[ Packagist](https://packagist.org/packages/vasily-kartashov/amazon-alexa-php)[ RSS](/packages/vasily-kartashov-amazon-alexa-php/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (19)Used By (0)

Amazon Alexa PHP Library
========================

[](#amazon-alexa-php-library)

[![Build Status](https://camo.githubusercontent.com/22fbb1142b23d952a3ebed194d04bbcfd0ec59a69bf3cc6b2a78582a8633c55e/68747470733a2f2f7472617669732d63692e6f72672f766173696c792d6b6172746173686f762f616d617a6f6e2d616c6578612d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vasily-kartashov/amazon-alexa-php)

This library provides provides some interface for developing Amazon Alexa Skills for your PHP app.

Consider this library work in progress and subject to rather significant API changes in the nearest future. Current implementation is garbage, but there's almost no alternative out there.

Usage
-----

[](#usage)

Install via composer: `vasily-kartashov/amazon-alexa-php`.

### Roadmap

[](#roadmap)

- Remove public access
- Add more unit tests
- Deprecate the old confusing API
- Add dependency on standard HTTP request object
- Add integration with Oauth-Server from php-league
- Stop throwing exceptions around
- Add LoggerAwareInterface
- Extract Certificate validation authority and add cacheing to it
- Add validator and dependency on [https://github.com/alexa/alexa-smarthome/tree/master/validation\_schemas](https://github.com/alexa/alexa-smarthome/tree/master/validation_schemas)

### Requests

[](#requests)

Create request by using a factory method `Request::fromHttpRequest` that accepts objects of type `RequestInterface` as defined by PSR-7. For example when using Guzzle one can initialize an Alexa request object by running:

```
$request = Request::fromHttpRequest(ServerRequest::fromGlobals(), $applicationId);
```

### Certificate validation

[](#certificate-validation)

By default the system validates the request signature by fetching Amazon's signing certificate and decrypting the signature. You need CURL to be able to get the certificate. No caching is done but you can override the Certificate class easily if you want to implement certificate caching yourself based on what your app provides:

Here is a basic example:

```
class MyAppCertificate extends \Alexa\Request\Certificate {
  public function getCertificate() {
    $cached_certificate = retrieve_cert_from_myapp_cache();
    if (empty($cached_certificate)) {
      // Certificate is not cached, download it
      $cached_ertificate = $this->fetchCertificate();
      // Cache it now
    }
    return $cached_certificate;
  }
}
```

And then in your app, use the setCertificateDependency function:

```
$certificate = new MyAppCertificate($_SERVER['HTTP_SIGNATURECERTCHAINURL'], $_SERVER['HTTP_SIGNATURE']);

$alexa = new \Alexa\Request\Request($rawRequest);
$alexa->setCertificateDependency($certificate);

$alexaRequest = $alexa->fromData();
```

### Application Id validation

[](#application-id-validation)

The library will automatically validate your Application Id matches the one of the incoming request - you don't need to do anything for that. If and only if you wish to change how the validation happens, you might use a similar scenario to the certificate validation - provide your own Application class extending the \\Alexa\\Request\\Application and providing a validateApplicationId() function as part of that. Pass your application to the Request library in a same way as the certificate:

```
$application = new MyAppApplication($myappId);
$alexa = new \Alexa\Request\Request($rawRequest, $myappId);
$alexa->setApplicationDependency($application);

$alexaRequest = $alexa->fromData();
```

### Response

[](#response)

You can build an Alexa response with the `Response` class. You can optionally set a card or a reprompt too.

Here's a few examples.

```
$response = new \Alexa\Response\Response;
$response->respond('Cooool. I\'ll lower the temperature a bit for you!')
	->withCard('Temperature decreased by 2 degrees');
```

```
$response = new \Alexa\Response\Response;
$response->respond('What is your favorite color?')
	->reprompt('Please tell me your favorite color');
```

To output the response, simply use the `->render()` function, e.g. in Laravel you would create the response like so:

```
return response()->json($response->render());
```

In vanilla PHP:

```
header('Content-Type: application/json');
echo json_encode($response->render());
exit;
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57% 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 ~69 days

Total

16

Last Release

2871d ago

PHP version history (3 changes)0.0.1PHP &gt;=5.4.0

0.1.6PHP &gt;=5.3.0

0.2.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/478df3662ef0b1865cfab9227c7f4cd5b000a92363d066ebf4280db05f739d13?d=identicon)[vasily-kartashov](/maintainers/vasily-kartashov)

---

Top Contributors

[![huntervk](https://avatars.githubusercontent.com/u/138185050?v=4)](https://github.com/huntervk "huntervk (45 commits)")[![korra88](https://avatars.githubusercontent.com/u/5181309?v=4)](https://github.com/korra88 "korra88 (14 commits)")[![MiniCodeMonkey](https://avatars.githubusercontent.com/u/220535?v=4)](https://github.com/MiniCodeMonkey "MiniCodeMonkey (8 commits)")[![vasily-kartashov](https://avatars.githubusercontent.com/u/875698?v=4)](https://github.com/vasily-kartashov "vasily-kartashov (7 commits)")[![jakubsuchy](https://avatars.githubusercontent.com/u/234124?v=4)](https://github.com/jakubsuchy "jakubsuchy (3 commits)")[![chris-hamper](https://avatars.githubusercontent.com/u/12731598?v=4)](https://github.com/chris-hamper "chris-hamper (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vasily-kartashov-amazon-alexa-php/health.svg)

```
[![Health](https://phpackages.com/badges/vasily-kartashov-amazon-alexa-php/health.svg)](https://phpackages.com/packages/vasily-kartashov-amazon-alexa-php)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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