stackkit/laravel-google-cloud-scheduler

v1.0.0-alpha2 2020-06-27 12:38 UTC

This package is auto-updated.

Last update: 2020-08-03 18:55:44 UTC


README

This is a WIP package

logo.png

Build Status Latest Stable Version License

Introduction

This package allows you to use Google Cloud Scheduler to schedule Laravel commands.

It only supports Artisan commands at this time due to security concerns.

How it works

Cloud Tasks will make a HTTP call to your application. This package adds an endpoint to your application that accepts the HTTP call and its payload (an Artisan command) and executes the command.

Requirements

This package requires Laravel 5.6 or higher.

Please check the table below for supported Laravel and PHP versions:

Laravel Version PHP Version
5.6 7.2 or 7.3
5.7 7.2 or 7.3
5.8 7.2 or 7.3 or 7.4
6.x 7.2 or 7.3 or 7.4
7.x 7.2 or 7.3 or 7.4

Installation

(1) Require the package using Composer

composer require stackkit/laravel-google-cloud-scheduler

(2) Define the STACKKIT_CLOUD_SCHEDULER_APP_URL environment variable. This should be the URL defined in the URL field of your Cloud Scheduler job.

STACKKIT_CLOUD_SCHEDULER_APP_URL=https://yourdomainname.com/cloud-scheduler-job

Cloud Scheduler Example

Here is an example job that will run php artisan inspire every minute.

These are the most important settings:

  • Target must be HTTP
  • URL must be https://yourdomainname.com/cloud-scheduler-job
  • Auth header must be OIDC token!

example.png

Planned features

Laravel's console kernel allows to execute actions after the command has finished running (such as ping a service) and prevent overlapping. This package does not support those features at this time. The goal is to eventually read the configured settings for a command (as defined in the console kernel) and execute the command exacty as defined there so that methods like thenPing and withoutOverlapping work out of the box without the need to configure anything.

Security

The job handler requires each request to have an OpenID token. Cloud Scheduler will generate an OpenID token and send it along with the job payload to the handler.

This package verifies that the token is digitally signed by Google and that it's meant for your application. Only Google Scheduler will be able to call your handler.

More information about OpenID Connect:

https://developers.google.com/identity/protocols/oauth2/openid-connect