All Projects → maxbeckers → Google Actions Php

maxbeckers / Google Actions Php

Licence: mit
This library is a helper for google actions / google home apps with php.

Projects that are alternatives of or similar to Google Actions Php

Hoobs
Build your Smart Home with HOOBS. Connect over 2,000 Accessories to your favorite Ecosystem.
Stars: ✭ 325 (+1610.53%)
Mutual labels:  google-home, google
Homeautio.mqtt.googlehome
Stars: ✭ 168 (+784.21%)
Mutual labels:  google-home, google
Playstoredownloader
A command line tool to download Android applications directly from the Google Play Store by specifying their package name (an initial one-time configuration is required)
Stars: ✭ 664 (+3394.74%)
Mutual labels:  google
Googleads Mobile Unity
Official Unity Plugin for the Google Mobile Ads SDK
Stars: ✭ 837 (+4305.26%)
Mutual labels:  google
Zmninja
High performance, cross platform ionic app for Home/Commerical Security Surveillance using ZoneMinder
Stars: ✭ 762 (+3910.53%)
Mutual labels:  home
Simplicity
A simple way to implement Facebook and Google login in your iOS apps.
Stars: ✭ 683 (+3494.74%)
Mutual labels:  google
Play Authenticate
An authentication plugin for Play Framework 2.x (Java)
Stars: ✭ 813 (+4178.95%)
Mutual labels:  google
Sou
简单搜索,一个简单的前端界面。用惯了各种导航首页,满屏幕尽是各种不厌其烦的广告和资讯;尝试自己写个自己的主页。
Stars: ✭ 628 (+3205.26%)
Mutual labels:  google
Pgclone
Visit the PG Repos @ https://github.com/PGBlitz - PGClone (PG's Mount & RClone Execution)
Stars: ✭ 18 (-5.26%)
Mutual labels:  google
Rules docker
Rules for building and handling Docker images with Bazel
Stars: ✭ 744 (+3815.79%)
Mutual labels:  google
Tensorlayer
Deep Learning and Reinforcement Learning Library for Scientists and Engineers 🔥
Stars: ✭ 6,796 (+35668.42%)
Mutual labels:  google
Mtrans
Multi-source Translation
Stars: ✭ 711 (+3642.11%)
Mutual labels:  google
Googletranslate
🌐 Google 翻译 Mac 客户端
Stars: ✭ 688 (+3521.05%)
Mutual labels:  google
Youtubeux
With MVVM Architecture pattern using Android Architecture Components This is a sample app demonstrating Youtube player animation using constraint layout
Stars: ✭ 823 (+4231.58%)
Mutual labels:  google
Cloudcomparer
Compare the various managed cloud services offered by the major public cloud providers in the market.
Stars: ✭ 678 (+3468.42%)
Mutual labels:  google
Schema Org
A fluent builder Schema.org types and ld+json generator
Stars: ✭ 894 (+4605.26%)
Mutual labels:  google
Assistant Relay
A Node.js server that allows for sending commands to Google Home/Assistant from endpoints
Stars: ✭ 638 (+3257.89%)
Mutual labels:  google-home
Bert
TensorFlow code and pre-trained models for BERT
Stars: ✭ 29,971 (+157642.11%)
Mutual labels:  google
Laravel Google Calendar
Manage events on a Google Calendar
Stars: ✭ 787 (+4042.11%)
Mutual labels:  google
Pygooglenews
If Google News had a Python library
Stars: ✭ 900 (+4636.84%)
Mutual labels:  google

Google actions php library

This library is a helper for google actions with php.

Install via composer

Require the package with composer:

composer require maxbeckers/google-actions-php

Usage

Handle the request:

  • map request data to request object
  • validate request
  • handle request data
  • create response
  • send response

Map request data to request object

Map needed request headers and request body to Request.

use MaxBeckers\GoogleActions\Request\Request;
...
$requestBody  = file_get_contents('php://input');
$googleRequest = Request::fromGoogleRequest($requestBody);

Validate request

The RequestValidator will handle the google request validation.

use MaxBeckers\GoogleActions\Validation\RequestValidator;
...
$validator = new RequestValidator();
$validator->validate($googleRequest);

Register request handlers

For different requests it's helpful to create different RequestHandlers.

use MaxBeckers\GoogleActions\RequestHandler\RequestHandlerRegistry;
...
$requestHandlerRegistry = new RequestHandlerRegistry();
$requestHandlerRegistry->addHandler($myRequestHandler);

Use registry to handle request

use MaxBeckers\GoogleActions\RequestHandler\RequestHandlerRegistry;
...
$requestHandler = $requestHandlerRegistry->getSupportingHandler($googleRequest);
$response       = $requestHandler->handleRequest($googleRequest);

Render response

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

Create a new request handler

The new request handler must extend AbstractRequestHandler. First implement the abstract supportsRequest-method.

public function supportsRequest(Request $request): bool
{
    return true; // check request data
}

Then implement the handleRequest-method. For simple responses there is a ResponseHelper.

use MaxBeckers\GoogleActions\Helper\ResponseHelper;
...
/** @var ResponseHelper */
private $responseHelper;
...
public function handleRequest(Request $request): Response
{
    // todo set needed response data
    return $responseHelper->respond('Success :)');
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].