Skip to content

Commit 71d82d6

Browse files
authored
Merge pull request #2 from a1comms/homogeneous
Initial Merge of Standard and Flexible Support
2 parents 367b071 + 769e23f commit 71d82d6

22 files changed

+909
-688
lines changed

LICENSE

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
The MIT License (MIT)
22

3+
Copyright (c) 2017 A1comms Ltd <[email protected]>
4+
35
Copyright (c) 2015 Ron Shpasser <[email protected]>
46

57
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -18,4 +20,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1820
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1921
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2022
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
23+
THE SOFTWARE.

README.md

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,91 @@
1-
# GaeFlexSupportL5
1+
# GaeSupportLaravel
22

3-
Google App Engine (GAE) Flexible Environment support package for Laravel 5.1.
3+
Google App Engine (GAE) Standard and Flexible Environment support package for Laravel 5.1.
44

5-
[![Latest Stable Version](https://poser.pugx.org/a1comms/gae-flex-support-l5/v/stable)](https://packagist.org/packages/a1comms/gae-flex-support-l5)
6-
[![Monthly Downloads](https://poser.pugx.org/a1comms/gae-flex-support-l5/d/monthly)](https://packagist.org/packages/a1comms/gae-flex-support-l5)
7-
[![Total Downloads](https://poser.pugx.org/a1comms/gae-flex-support-l5/downloads)](https://packagist.org/packages/a1comms/gae-flex-support-l5)
8-
[![Latest Unstable Version](https://poser.pugx.org/a1comms/gae-flex-support-l5/v/unstable)](https://packagist.org/packages/a1comms/gae-flex-support-l5)
9-
[![License](https://poser.pugx.org/a1comms/gae-flex-support-l5/license)](https://packagist.org/packages/a1comms/gae-flex-support-l5)
5+
[![Latest Stable Version](https://poser.pugx.org/a1comms/gae-support-laravel/v/stable)](https://packagist.org/packages/a1comms/gae-support-laravel)
6+
[![Monthly Downloads](https://poser.pugx.org/a1comms/gae-support-laravel/d/monthly)](https://packagist.org/packages/a1comms/gae-support-laravel)
7+
[![Total Downloads](https://poser.pugx.org/a1comms/gae-support-laravel/downloads)](https://packagist.org/packages/a1comms/gae-support-laravel)
8+
[![Latest Unstable Version](https://poser.pugx.org/a1comms/gae-support-laravel/v/unstable)](https://packagist.org/packages/a1comms/gae-support-laravel)
9+
[![License](https://poser.pugx.org/a1comms/gae-support-laravel/license)](https://packagist.org/packages/a1comms/gae-support-laravel)
1010

11-
Based on origional work for App Engine Standard by @shpasser https://github.com/shpasser/GaeSupportL5
11+
Based on original work for App Engine Standard by @shpasser https://github.com/shpasser/GaeSupportL5
12+
13+
This library is designed for homogeneous operation between the Standard Environment and the Flexible Environment, with the only change required being a different prepare command before deployment.
1214

1315
Currently supported features:
14-
* File system compatibility (write files to `/tmp/laravel/storage`).
16+
* File system compatibility (write files to `cachefs` or `/tmp/laravel/storage`).
1517
* Automatically cache and patch configuration files.
16-
* DataStore persistent session handler.
18+
* Datastore persistent session handler.
19+
* Full microservice support in the session handler, by including `gae_service()` in the storage key.
20+
* Full microservice and version support in `cachefs`, so versions and services in the Standard Environment don't conflict.
1721

18-
## Installation
22+
## Installation
1923

20-
Pull in the package via Composer.
24+
Pull in the package via Composer.
2125

22-
```js
26+
```js
2327
"require": {
24-
"a1comms/gae-flex-support-l5": "~5.1"
28+
"a1comms/gae-support-laravel": "~5.1"
2529
}
26-
```
30+
```
2731

28-
Then include the service provider within `config/app.php`.
32+
Then include the service provider within `config/app.php`.
2933

30-
```php
34+
```php
3135
'providers' => [
3236
A1comms\GaeFlexSupportL5\GaeSupportServiceProvider::class
3337
];
34-
```
38+
```
39+
40+
To automatically patch your configuration files ready for use with GAE, run the setup command:
41+
42+
```bash
43+
php artisan gae:setup
44+
```
3545

3646
## Deployment & Local Development
37-
Before deployment, you'll need to run the config patcher which will prepare for running in the live environment.
47+
Before deployment, you'll need to run the prepare command which will prepare for running in the live environment.
48+
49+
This will ask Laravel to generate a config/route cache so it doesn't need to generate it on live while the file system is read-only, plus it'll patch some additional values in this cache file, since there is more exposed here than can be changed in the raw config files.
3850

3951
```bash
40-
php artisan gae:setup --cache-config
52+
php artisan gae:prepare env
4153
```
4254

55+
Replace `env` with the environment you'll be running on, std (Standard) or flex (Flexible).
56+
4357
This will also manage your `.env` files for you, moving `.env` to `.env.local` and `.env.production` to `.env` (if `.env.production` exists).
4458

4559
To revert back to a local development state, you can run the local development prepare command.
4660

4761
```bash
48-
php artisan gae:setup --local-dev
62+
php artisan gae:prepare local
4963
```
5064

51-
This will move `.env` to `.env.production` and `.env.local` to `.env` (if `.env.local` exists) and also re-generate the config cache without any modifications.
65+
This will move `.env` to `.env.production` and `.env.local` to `.env` (if `.env.local` exists) and also re-generate the config cache to revert any patches/modifications required to run on the live environment.
5266

5367
## Automatic changes when GAE is detected.
54-
When GAE is detected at runtime, a few changes are automatically applied:
68+
When GAE Standard is detected at runtime, a few changes are automatically applied:
69+
* The syslog handler is loaded and forced to be the default monolog handler.
70+
* The storage directory is re-written to `cachefs://` which is an emulated file-system on top of memcache.
71+
72+
When GAE Flexible is detected at runtime, these changes are automatically applied:
5573
* The structured log handler is loaded and forced to be the default monolog handler.
5674
* The `gs://` stream wrapper is loaded with the default credentials from the underlying GCE instance.
5775
* The storage directory is changed to `/tmp/laravel/storage`
5876

5977
## Temporary Storage
60-
By default, we set the temporary storage directory to `/tmp/laravel/storage`.
78+
By default, we set the temporary storage directory to `cachefs://` on Standard and `/tmp/laravel/storage` on Flexible.
6179

6280
This will store things like the framework cache files (services.json, routes.php & config.php), as well as the compiled views.
6381

64-
This storage will be unique per instance and ephemeral, so it isn't suitable for storing caches of application data, e.g. from a DB.
82+
The storage on Flexible will be unique per instance and ephemeral, so it isn't suitable for storing caches of application data, e.g. from a DB.
83+
84+
Since deploying new code or config would mean deploying a new version, we can safely cache the config & views here.
85+
86+
The storage on the Standard Environment is shared between all instances, but can clear at any time, so we've included a few modifications to prevent issues.
6587

66-
Since deploying new code or config would mean deploying a new version, we can safely cache the config & views.
88+
The main one is an altered Blade compiler, with an `isExpired` function that reads the whole view cache rather than checking if the file exists, which in turn causes the modified `cachefs` driver to create a local in-memory cache of the contents using variables, so it isn't affected if memcache is cleared between the `isExpired` check and the actual view rendering, which we used to see causing quite a few fatal errors.
6789

6890
### Persistent Sessions in DataStore
6991

@@ -72,4 +94,4 @@ We've included a session driver using DataStore for persistence, cached by memca
7294
To make use of this, set:
7395
- `SESSION_DRIVER=gae` in `.env`
7496

75-
(*) memcache code is included, but since it isn't currently available on the Flexible environment, this won't function for now.
97+
(*) memcache code is included, but since it isn't currently available on the Flexible environment, this won't function on there for now.

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
{
2-
"name": "a1comms/gae-flex-support-l5",
3-
"description": "Google App Engine Flexible Runtime Support for Laravel 5.1 apps.",
2+
"name": "a1comms/gae-support-laravel",
3+
"description": "Google App Engine (Standard and Flexible Environment) runtime support for Laravel apps.",
44
"license": "MIT",
55
"authors": [
66
{
77
"name": "Samuel Melrose",
8-
"email": "sam@infitialis.com"
8+
"email": "sam.melrose@a1comms.com"
99
}
1010
],
1111
"require": {
12-
"php": ">=5.4.0",
12+
"php": ">=5.5.9",
1313
"illuminate/support": "~5.1",
1414
"illuminate/session": "~5.1",
1515
"league/flysystem": "~1.0",
1616
"tomwalder/php-gds": "~3.0",
17-
"google/cloud": "^0.28"
17+
"google/cloud": "dev-batch"
1818
},
1919
"require-dev": {
2020
"phpunit/phpunit": "~4.4"
2121
},
2222
"autoload": {
2323
"psr-4": {
24-
"A1comms\\": "src/A1comms"
24+
"A1comms\\GaeSupportLaravel\\": "src/A1comms/GaeSupportLaravel/"
2525
},
2626
"files": [
2727
"src/helpers.php"
2828
]
2929
},
30-
"minimum-stability": "stable"
30+
"minimum-stability": "dev"
3131
}

src/A1comms/GaeFlexSupportL5/Logger/AppEngineFlexFormatter.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)