kevin-mitchell / alexa-app

Set of classes to make creating Amazon Alexa Skills Kit (ASK) applications easier with Laravel and Lumen
MIT License
97 stars 47 forks source link

Non-static functions #22

Open mattrabe opened 7 years ago

mattrabe commented 7 years ago

In implementing this I have run into numerous issues, but the central issue I'm seeing seems to relate to the fact that all of the functions in src/Alexa.php are public, non-static functions, yet your readme indicates that they should be called statically. You list Alexa::say("Hello") and Alexa::slot('choice') in your readme, but both functions are non-static. Simply changing say() to a public static function resolves the issue for that function, but the slot() function references $this within itself, and therefore cannot be changed to a static function. Are there unpushed commits or something else I am missing here?

develpr commented 7 years ago

Just to check, did you register the facades as outlined here? https://github.com/develpr/alexa-app#2-adding-the-facadesaliases-for-alexa-and-alexaroute-optional - long story short without registering those you wouldn't be able to do things like Alexa::say(..., etc.

I'm guessing you perhaps have, and that the issue is "deeper", but I wanted to double check!

mattrabe commented 7 years ago

Yes, I did enable the facades in bootstrap/app.php like this:

$app->withFacades(); class_alias(\Develpr\AlexaApp\Facades\AlexaRouter::class, 'AlexaRoute'); class_alias(\Develpr\AlexaApp\Facades\Alexa::class, 'Alexa');

mattrabe commented 7 years ago

For what it's worth I've forked this repo and made changes on a new branch lumen-5.1.7 so that I am able to use static functions at least in some cases in Lumen 5.1.7: https://github.com/mattrabe/alexa-app/tree/lumen-5.1.7