[READ ONLY] Runtime for Google Cloud

Overview

Google Cloud Runtime

A runtime for Google Cloud.

If you are new to the Symfony Runtime component, see the "The Long Story" down below.

Installation

This runtime layer is special. It includes a router.php to enable the use of Symfony Runtime component. You need to install this package and the runtime you want to use.

To use with native or Symfony application.

composer require runtime/google-cloud symfony/runtime

If you want to use it with PSR-7.

composer require runtime/google-cloud runtime/psr-nyholm

Usage

Define the environment variable FUNCTION_SOURCE.

# Default value
FUNCTION_SOURCE=index.php

Note that Google Cloud requires you to have an index.php file. If you are running Symfony you probably want to define FUNCTION_SOURCE=public/index.php but you still need to create an index.php.

<?php
// index.php
// This file is needed for google cloud

Using CloudEvent

// index.php
use Google\CloudFunctions\CloudEvent;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function(CloudEvent $cloudevent) {
    // Print the whole CloudEvent
    $stdout = fopen('php://stdout', 'wb');
    fwrite($stdout, $cloudevent);
};

Troubleshooting

Cache/Build Directory

Note that Google Cloud will only deploy files that are not in .gitignore. You need to remove the var/ entry before deployment to be able to warm up the cache etc.

Define Symfony Environment

Define environment variable APP_ENV=prod to use Symfony production mode.

gcloud functions deploy helloHttp \
 --runtime php74 \
 --trigger-http \
 --allow-unauthenticated \
 --set-env-vars "FUNCTION_SOURCE=public/index.php,APP_ENV=prod"

The Long Story

This section is for you who are new to Symfony Runtime component.

Symfony Runtime component will be released with Symfony 5.3 in May 2021. Here is the official documentation there is also a compressed version in the main readme.

Every Symfony application from Symfony 5.3 will be created with this component as default. The component makes sure your application is decoupled from the global state. Which means your application is very portable. With some config (or automatic mapping) a RuntimeInterface is used as the "glue" between Nginx and your application.

Of course, different RuntimeInterface "glue" between different things. One Runtime is for Google Cloud, one for Bref/AWS, one for Swoole, one for RoadRunner etc. The point is that your application does not care what runtime it is. This means that you can run your application locally with a normal web server (like Nginx) and deploy it to Google Cloud with zero changes and still be sure everything works.

Google Cloud Runtime Specifically

Since Google Cloud is very similar to a "normal web server", this runtime only contains 2 things:

  1. router.php which is a requirement from Google Cloud. Its job is just to redirect the request to the front controller. It is not used locally.
  2. Support for CloudEvent. If you write an application that expects a Google\CloudFunctions\CloudEvent this runtime will automatically detect that and create such object for you.

It will support native PHP applications and Symfony HttpFoundation type applications out-of-the-box. To support PSR-7/PSR-15 or Laravel, one also need to install one additional runtime. See main readme for more information.

You might also like...
 Google Two-Factor Authentication Package for Laravel
Google Two-Factor Authentication Package for Laravel

Google2FA for Laravel Google Two-Factor Authentication Package for Laravel Google2FA is a PHP implementation of the Google Two-Factor Authentication M

Cipi is a Laravel based cloud server control panel that supports Digital Ocean, AWS, Vultr, Google Cloud, Linode, Azure and other VPS.
Cipi is a Laravel based cloud server control panel that supports Digital Ocean, AWS, Vultr, Google Cloud, Linode, Azure and other VPS.

Cipi is a Laravel based cloud server control panel that supports Digital Ocean, AWS, Vultr, Google Cloud, Linode, Azure and other VPS. It comes with nginx, Mysql, multi PHP-FPM versions, multi users, Supervisor, Composer, npm, free Let's Encrypt certificates, Git deployment, backups, ffmpeg, fail2ban, Redis, API and with a simple graphical interface useful to manage Laravel, Codeigniter, Symfony, WordPress or other PHP applications. With Cipi you don’t need to be a Sys Admin to deploy and manage websites and PHP applications powered by cloud VPS.

Get estimated read time of an article. Similar to medium.com's "x min read". Multilingual including right-to-left written languages. Supports JSON, Array and String output.

Read Time Calculates the read time of an article. Output string e.g: x min read or 5 minutes read. Features Multilingual translations support. Static

[READ-ONLY] Easy to use Caching library with support for multiple caching backends. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Caching Library The Cache library provides a Cache service locator for interfacing with multiple caching backends using a simple to use interf

[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)

Illuminate Database The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style OR

[READ-ONLY] A flexible, lightweight and powerful Object-Relational Mapper for PHP, implemented using the DataMapper pattern. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP ORM The CakePHP ORM provides a powerful and flexible way to work with relational databases. Using a datamapper pattern the ORM allows you to m

[READ-ONLY] Collection library in CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Collection Library The collection classes provide a set of tools to manipulate arrays or Traversable objects. If you have ever used underscore

[READ-ONLY] The event dispatcher library for CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Event Library This library emulates several aspects of how events are triggered and managed in popular JavaScript libraries such as jQuery: An

[READ-ONLY] Validation library from CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Validation Library The validation library in CakePHP provides features to build validators that can validate arbitrary arrays of data with eas

[READ-ONLY] CakePHP Utility classes such as Inflector, Text, Hash, Security and Xml. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Utility Classes This library provides a range of utility classes that are used throughout the CakePHP framework What's in the toolbox? Hash A

Read-only WebDAV server written in php8.0; supports browsing archives and GETting files in encodings other than what's on disk

Best Read-only WebDAV Server: TODO Features and notes of implementation Keeping generated files in a place that nginx can find them (2 ways to do this

[READ ONLY] WordPress-specific Comment data model

Comments WordPress-specific Comment Data Model Install Via Composer composer require pop-wp-schema/comments Development The source code is hosted on t

[READ-ONLY] The Pheanstalk Enqueue transport.

Supporting Enqueue Enqueue is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and

[READ-ONLY] Properties define model metadata.

Charcoal Property Properties define object's metadata. They provide the building blocks of the Model's definition. Properties are defined globally for

WeExpire is an opensource tool for creating emergency notes that can be read by your trusted contacts only after your death or if you are seriously injured

WeExpire is an opensource tool for creating emergency notes that can be read by your trusted contacts only after your death or if you are

Remember your query results using only one method. Yes, only one.

Cache Query Remember your query results using only one method. Yes, only one. Articles::latest('published_at')-cache()-take(10)-get(); Keep this pa

PHP Japanese string helper functions for converting Japanese strings from full-width to half-width and reverse. Laravel Rule for validation Japanese string only full-width or only half-width.

Japanese String Helpers PHP Japanese string helper functions for converting Japanese strings from full-width to half-width and reverse. Laravel Rule f

Centreon is a network, system and application monitoring tool. Centreon is the only AIOps Platform Providing Holistic Visibility to Complex IT Workflows from Cloud to Edge.
Centreon is a network, system and application monitoring tool. Centreon is the only AIOps Platform Providing Holistic Visibility to Complex IT Workflows from Cloud to Edge.

Centreon - IT and Application monitoring software Introduction Centreon is one of the most flexible and powerful monitoring softwares on the market;

Flysystem adapter for Google Cloud Storage
Flysystem adapter for Google Cloud Storage

Flysystem adapter for Google Cloud Storage This package contains a Google Cloud Storage driver for Flysystem. Notice This package is a fork from super

Releases(0.1.1)
Owner
Runtime
Runtime
Discuz!ML is a multilingual version of Discuz!X, social network engine from Tencent Cloud

Discuz! ML (MultiLingual Discuz) Introduction Discuz!ML is a multilingual version of Discuz!X, social network engine from Tencent Cloud Related Sites

Valery Votintsev 3 Dec 7, 2022
Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.

Hybridauth 3.7.1 Hybridauth enables developers to easily build social applications and tools to engage websites visitors and customers on a social lev

hybridauth 3.3k Dec 23, 2022
A One Time Password Authentication package, compatible with Google Authenticator.

Google2FA Google Two-Factor Authentication for PHP Google2FA is a PHP implementation of the Google Two-Factor Authentication Module, supporting the HM

Antonio Carlos Ribeiro 1.6k Dec 30, 2022
Google Auth Library for PHP

This is Google's officially supported PHP client library for using OAuth 2.0 authorization and authentication with Google APIs.

Google APIs 1.2k Jan 4, 2023
Simple PHP Google Authentication Template

php-google-auth A php google authentication page project View Demo · Report Problems About The Project This is a small and easy project that I made to

Antonio 4 Nov 21, 2021
Login Menggunakan Google, Github, & Facebook

Login Oauth 2 Karena agak rumit untuk menjelaskan, ikuti tutorial berikut untuk mengatur CLIENTID dan CLIENTSECRET mu terlebih dahulu klik. Server Req

Fadhlurrahman 1 Nov 24, 2021
Social OAuth Authentication for Laravel 5. drivers: facebook, github, google, linkedin, weibo, qq, wechat and douban

Social OAuth Authentication for Laravel 5. drivers: facebook, github, google, linkedin, weibo, qq, wechat and douban

安正超 330 Nov 14, 2022
PHP class to generate and verify Google Authenticator 2-factor authentication

Google Authenticator PHP class Copyright (c) 2012-2016, http://www.phpgangsta.de Author: Michael Kliewe, @PHPGangsta and contributors Licensed under t

Michael Kliewe 2.1k Jan 2, 2023
Enables Google Authentication for YOURLS

google-auth-yourls Enables Google Authentication for YOURLS Proper documentation coming soon. For now, here is the very rough documentation: Download

8th Wall 14 Nov 20, 2021
Opauth strategy for Google authentication

Opauth-Google Opauth strategy for Google authentication.

Opauth – PHP Auth Framework 84 Dec 4, 2022