PHPackages                             skollro/alexa-php-sdk - 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. skollro/alexa-php-sdk

ActiveLibrary[API Development](/categories/api)

skollro/alexa-php-sdk
=====================

Expressive SDK for developing Amazon Alexa skills in PHP.

v1.1.0(7y ago)288.9k↓37%4MITPHP

Since Dec 2Pushed 5y ago2 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

Amazon Alexa SDK for PHP
========================

[](#amazon-alexa-sdk-for-php)

[![Latest Version](https://camo.githubusercontent.com/f2558e57d8011f85e6b610b2514990cdc1a9bcf869095822dfdbb778717f06d8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f736b6f6c6c726f2f616c6578612d7068702d73646b2e7376673f7374796c653d666c61742d737175617265)](https://github.com/skollro/alexa-php-sdk/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/18b5d07ae32cb942c2623e025de0295ea7a9c31f281bdbece3e4868c5e9c4e1c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f736b6f6c6c726f2f616c6578612d7068702d73646b2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/skollro/alexa-php-sdk)[![StyleCI](https://camo.githubusercontent.com/30307285e28c76bb4d35496938379d93cb81b5af8876880e3cd739b268bbf80f/68747470733a2f2f7374796c6563692e696f2f7265706f732f3135393837353033332f736869656c64)](https://styleci.io/repos/159875033)

This package provides a framework-agnostic expressive SDK for developing Alexa skills in PHP based on .

```
use Skollro\Alexa\Alexa;
use MaxBeckers\AmazonAlexa\Request\Request;

$request = Request::fromAmazonRequest(file_get_contents('php://input'), $_SERVER['HTTP_SIGNATURECERTCHAINURL'], $_SERVER['HTTP_SIGNATURE']);

Alexa::skill('amzn1.ask.skill.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX')
    ->intent('HelloIntent', function ($request, $response) {
        $response->say('Hello');
    })
    ->handle($request, function ($response) {
        header('Content-Type: application/json');
        echo json_encode($response);
    });
```

Disclaimer
----------

[](#disclaimer)

***This package is no official Amazon Alexa SDK.***

Until now this package does not support every operation which might be needed for writing Alexa skills but is a solid foundation. So feel free to PR missing features.

Install
-------

[](#install)

You can install this package via composer:

```
composer require skollro/alexa-php-sdk
```

Usage
-----

[](#usage)

### Create a skill and handle requests

[](#create-a-skill-and-handle-requests)

Use the following code as starting point for your own skill. First you have to create a `Request` object from the POST request's data. Then create a new skill with `Alexa::skill($applicationId)`, passing your application id. Finally define your request handers and call `handle($request)` which handles the request and creates a response.

```
use MaxBeckers\AmazonAlexa\Request\Request;

$request = Request::fromAmazonRequest(file_get_contents('php://input'), $_SERVER['HTTP_SIGNATURECERTCHAINURL'], $_SERVER['HTTP_SIGNATURE']);

$alexa = Alexa::skill('amzn1.ask.skill.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');

// define middlewares and request handlers...

$response = $alexa->handle($request);

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

### Middlewares

[](#middlewares)

All requests are piped through several middlewares before the request handler is invoked. Remember to return `$next($request, $response)` to invoke the next middleware in the chain. If you return a `$response` from a middleware no other handlers are invoked and `$response` is returned immediately.

#### Automatically attached middlewares

[](#automatically-attached-middlewares)

When creating a skill with `Alexa::skill($applicationId)` we automatically attach the following two middlewares.

- **Skollro\\Alexa\\VerifyRequest:** Verifies if the request is coming from the Amazon Echo API and checks signatures.
- **Skollro\\Alexa\\VerifyApplicationId:** Verifies if the request is intended for your application.

#### Before middleware

[](#before-middleware)

Checking for an access token is a typical use case for a middleware which runs before the request handler.

```
$alexa->middleware(function ($next, $request, $response) {
    if (! $request->context->system->user->accessToken) {
        return $response->say('Link your account')->linkAccount();
    }

    return $next($request, $response);
});
```

#### After middleware

[](#after-middleware)

To run a middleware after the request handler, store the result of `$next($request, $response)` in a temporary variable and return the response later.

```
$alexa->middleware(function ($next, $request, $response) {
    $response = $next($request, $response);

    // modify $response here...

    return $response;
});
```

### Request handlers

[](#request-handlers)

Amazon Echo API sends different types of requests to your application. Use those callbacks to implement your skill's logic. You can use invokable classes for better encapsulation.

```
class BarIntent
{
    public function __invoke($request, $response)
    {
        $response->say('Use an invokable class as request handler');
    }
}

$alexa->launch(function ($request, $response) {
    $response->say('Welcome to your skill');
});

$alexa->intent('HelloIntent', function ($request, $response) {
    $response->say('Hello world');
});

$alexa->intent('BarIntent', new BarIntent);
```

### Responses

[](#responses)

You can make use of a fluent and natural syntax for creating responses.

```
$alexa->intent('HelloIntent', function ($request, $response) {
     // Basic response
    $response->say('Hello world');

    // Use cards for showing information in a user's Alexa App
    $response->simple($title, $content);
    $response->standard($title, $content, $smallImageUrl, $largeImageUrl);
    $response->linkAccount();

    // Use fluent syntax
    $response->say('Link your account')->linkAccount();
});
```

### Exceptions

[](#exceptions)

If you throw an exception in a request handler we invoke this callback so you can handle exceptions there.

```
$alexa->exception(function ($e, $request, $response) {
    if ($e instanceof MyException) {
        return $response->say('An error occurred');
    }

    throw $e;
});
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~4 days

Total

2

Last Release

2719d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8849605?v=4)[Simon Kollross](/maintainers/skollro)[@skollro](https://github.com/skollro)

---

Top Contributors

[![skollro](https://avatars.githubusercontent.com/u/8849605?v=4)](https://github.com/skollro "skollro (35 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/skollro-alexa-php-sdk/health.svg)

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

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