Download the PHP package codecommerce/alexaapi without Composer

On this page you can find all versions of the php package codecommerce/alexaapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package alexaapi

Installation

composer require codecommerce/alexaapi 

Creating directories and config files

Mac OS

mkdir -p Alexa/Config && cp vendor/codecommerce/alexaapi/Config/* Alexa/Config && mkdir Alexa/Intents

Windows

mkdir Alexa
cd Alexa
mkdir Config
mkdir Intents
xcopy ../vendor/codecommerce/alexaapi/Config ./Config /e /i /h

Projekt composer.json

Erstelle eine composer.json in deinem Projektordner. Fordere via require die AlexaApi an. Schreibe deinen Namespace in in autoload -> psr-4

{
    "require": {
        "codecommerce/alexaapi": "^1.0"
    },
    "autoload": {
        "psr-4": {
            "AlexaSpielwiese\\Alexa\\": "./Alexa"
        }
    }
}

Erster Intent

Erstelle eine Klasse und gebe den Namespace (siehe Projekt composer.json) an. Implementire das Interface 'IntentsInterface'. Übernehme die Methoden die das Interface vorraussetzt. Du kanns im Konstruktor die Variablen $sytem und $request auf eine Klassenvariable legen und somit überall verwenden.

<?php

namespace AlexaSpielwiese\Alexa\Intents;

use CodeCommerce\AlexaApi\Intents\IntentsInterface;
use CodeCommerce\AlexaApi\Model\Request;
use CodeCommerce\AlexaApi\Model\System;

class TestIntent implements IntentsInterface
{
    protected $request;
    protected $system;

    /**
     * IntentsInterface constructor.
     * @param Request $request
     * @param System  $system
     */
    public function __construct(Request $request, System $system)
    {
        $this->request = $request;
        $this->system = $system;
    }

    /**
     * @return mixed
     */
    public function runIntent()
    {
        // TODO: Implement runIntent() method.
    }
}

In der Methode runIntent passiert die ganze Magic.

Routing

Füge deine neue Klasse in das Routing ein.

Alexa/Config/routes.yml

Der Intent muss den gleichen Namen haben wie in der Developer Konsole bei Amazon

routes.yml

TestIntent: AlexaSpielwiese\Alexa\Intents\TestIntent

Die API macht nun den Rest und geht auf deinen hinterlegten Intent.

Prüfen auf Display

Du kannst dir das Display-Ausgabegerät vom $system zurückgeben lassen und somit prüfen ob es eine Displayunterstützung gibt.

$this->system->hasViewport()

Endpoint Konfigurieren

Die Datei die den Endpoint darstellt muss folgenden Aufruf erhalten

require __DIR__ . '/../vendor/autoload.php';
new CodeCommerce\AlexaApi\Controller\RequestHandler();

Hello World

Um eine Ausgabe zu erhalten nutzen Sie diese Methode

 /**
 * @return mixed
 */
public function runIntent()
{
    $outSpeech = new Outspeech('Hello World');
    $response = new Response($outSpeech);
    (new ResponseHandler())->send($response);
}

Hintergrundbild hinzufügen

$backgroundImage = new BackgroundImage();
$backgroundImage->setSources('DEINE_URL');

$response = new Response($outspeech);

if ($this->system->getDisplay()) {
    $template = new Template();
    $template->setBackgroundImage($backgroundImage)
        ->setPrimary('Text 1')
        ->setSecondary('Text 2')
        ->setTertiary('Text 3')
        ->setType($template::BODY_TEMPLATE_2_IMAGE_LIMITED_CENTERED_TEXT);

    $directive = new Directives();
    $directive->setTemplate($template);
    $response->setDirectives($directive);
}

All versions of alexaapi with dependencies

PHP Build Version
Package Version
Requires monolog/monolog Version ^1.23
symfony/yaml Version ^4.1
symfony/serializer Version ^4.1
symfony/property-access Version ^4.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package codecommerce/alexaapi contains the following files

Loading the files please wait ....