PHPackages                             froodley/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. froodley/amazon-alexa-php

ActiveLibrary[API Development](/categories/api)

froodley/amazon-alexa-php
=========================

Amazon Alexa interface for PHP - XSS Filtering, Improved Testability

0.5.2.5(8y ago)81.1k3MITPHPPHP &gt;=5.5.9

Since Aug 26Pushed 8y ago2 watchersCompare

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

READMEChangelog (10)Dependencies (4)Versions (58)Used By (0)

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

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

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

It represents a breaking change (and is forked) from jakobsuchy/amazon-alexa-php

The most important changes are the addition of XSS purification and some basic Doctrine validation, and making everything stateless, SRP and more testable

Usage
-----

[](#usage)

Install via composer: `composer require froodley/amazon-alexa-php`

### Requests

[](#requests)

When Amazon Alexa triggers your skill, a HTTP request will be sent to the URL you specified for your app.

You can get the `JSON` body of the request like so:

```
$applicationId = "your-application-id-from-alexa"; // See developer.amazon.com and your Application. Will start with "amzn1.echo-sdk-ams.app."
$rawRequest = $request->getContent(); // This is how you would retrieve this with Laravel or Symfony 2.
$alexaRequestFactory = new \Alexa\Request\RequestFactory();
$alexaRequest = $alexaRequestFactory->fromRawData($rawRequest, [$applicationId]);
```

The library expect raw request data, not parsed JSON as it needs to validate the request signature.

You can determine the type of the request with `instanceof`, e.g.:

```
if ($alexaRequest instanceof IntentRequest) {
	// Handle intent here
}
```

### 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

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 51.9% 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 ~15 days

Recently: every ~55 days

Total

54

Last Release

3177d ago

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

0.1.6PHP &gt;=5.3.0

0.4.0PHP &gt;=5.5.9

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1268363?v=4)[Pete Burkindine](/maintainers/froodley)[@froodley](https://github.com/froodley)

---

Top Contributors

[![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)")[![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)")

---

Tags

echoAlexaAmazon Echoamazon-alexa

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M717](/packages/sylius-sylius)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k16.8k](/packages/prestashop-prestashop)[oro/platform

Business Application Platform (BAP)

642140.7k105](/packages/oro-platform)[maxbeckers/amazon-alexa-php

Php library for amazon echo (alexa) skill development.

11557.7k2](/packages/maxbeckers-amazon-alexa-php)

PHPackages © 2026

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