PHP code example of b00gizm / alexa-skill

1. Go to this page and download the library: Download b00gizm/alexa-skill library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

b00gizm / alexa-skill example snippets


$factory = new Alexa\EventFactory();
$alexa = new Alexa\Alexa($factory);
$alexa->onLaunchRequest(function(Alexa\Alexa $alexa, Alexa\LaunchRequest $request, Alexa\Session $session) {
    return $alexa->getResponse()->addPlainTextOutputSpeech("Welcome to my awesome app!");
});

return new JsonResponse($alexa->process($requestJson));

$alexa->onLaunchRequest(function(Alexa\Alexa $alexa, Alexa\LaunchRequest $request, Alexa\Session $session) { ... });
$alexa->onIntentRequest(function(Alexa\Alexa $alexa, Alexa\Intent $intent, Alexa\LaunchRequest $request, Alexa\Session $session) { ... });
$alexa->onSessionEndedRequest(function(Alexa\Alexa $alexa, Alexa\LaunchRequest $request, Alexa\Session $session) { ... });

$factory = new Alexa\EventFactory();

$processor = new Alexa\EventProcessor();
$processor->setLaunchHandler(new MyLaunchHandler());
$processor->setIntentHandlers([
    new MyFooIntentHandler(),
    new MyBarIntentHandler(),
]);
$processor->setSessionEndedHandler(new MySessionEndedHandler());

$alexa = new Alexa\Alexa($factory, $processor);

\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');