An Amazon Alexa PHP API designed to run standalone or part of a Laravel Application
Requirements:
- PHP 8.0
- Alexa login
You can install the package via composer:
composer require fintech-systems/alexa-api
Please see TROUBLESHOOTING for more information on how to troubleshoot Amazon Alexa API integration.
- Alexa sends a message to the intermediate API endpoint
- The intermediate API system sends an API request to the actual API
- The actual API responds and sends the message back to the intermediate endpoint,
- ...who passes it back to the Alexa API
- ...which makes Alexa do something / speak
The .env file needs this setting:
VOICE_API_URL="http://bas.fintechsystems.net/api/v1/"
<?php
use FintechSystems\Api\Alexa;
require 'vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
$server = [
'api_url' => $_ENV['TECHNOLOGY_API_URL'],
'api_key' => $_ENV['TECHNOLOGY_API_KEY'],
'api_secret' => $_ENV['TECHNOLOGY_API_SECRET'],
];
$api = new Technology($server);
$result = $api->getInformation();
You can publish the config file with:
php artisan vendor:publish --provider="FintechSystems\Alexa\AlexaServiceProvider" --tag="alexa-api-config"
Framework Agnostic PHP:
$newRecord = ['test1', 'test2'];
$api = new Technology;
$api->post($test);
Laravel App:
$newRecord = ['test1', 'test2'];
Technology::post($newRecord);
Expected result:
A new record is added.
vendor/bin/phpunit
Use the command below to run tests that excludes touching the API:
vendor/bin/phpunit --exclude-group=live
The storage
folder has examples API responses, also used for caching during tests.
To regenerate coverage reports:
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html=tests/coverage-report
See also .travis.yml
For local editing, add this to composer.json
:
"repositories" : [
{
"type": "path",
"url": "../technology-api"
}
]
Then in require
section:
"fintech-systems/technology-api": "dev-main",
This application uses Semantic Versioning as per https://semver.org/
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.