You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on origional work for App Engine Standard by @shpasserhttps://github.com/shpasser/GaeSupportL5
11
+
Based on original work for App Engine Standard by @shpasserhttps://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.
12
14
13
15
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`).
15
17
* 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.
17
21
18
-
## Installation
22
+
## Installation
19
23
20
-
Pull in the package via Composer.
24
+
Pull in the package via Composer.
21
25
22
-
```js
26
+
```js
23
27
"require": {
24
-
"a1comms/gae-flex-support-l5":"~5.1"
28
+
"a1comms/gae-support-laravel":"~5.1"
25
29
}
26
-
```
30
+
```
27
31
28
-
Then include the service provider within `config/app.php`.
32
+
Then include the service provider within `config/app.php`.
To automatically patch your configuration files ready for use with GAE, run the setup command:
41
+
42
+
```bash
43
+
php artisan gae:setup
44
+
```
35
45
36
46
## 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.
38
50
39
51
```bash
40
-
php artisan gae:setup --cache-config
52
+
php artisan gae:prepare env
41
53
```
42
54
55
+
Replace `env` with the environment you'll be running on, std (Standard) or flex (Flexible).
56
+
43
57
This will also manage your `.env` files for you, moving `.env` to `.env.local` and `.env.production` to `.env` (if `.env.production` exists).
44
58
45
59
To revert back to a local development state, you can run the local development prepare command.
46
60
47
61
```bash
48
-
php artisan gae:setup --local-dev
62
+
php artisan gae:prepare local
49
63
```
50
64
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.
52
66
53
67
## 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:
55
73
* The structured log handler is loaded and forced to be the default monolog handler.
56
74
* The `gs://` stream wrapper is loaded with the default credentials from the underlying GCE instance.
57
75
* The storage directory is changed to `/tmp/laravel/storage`
58
76
59
77
## 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.
61
79
62
80
This will store things like the framework cache files (services.json, routes.php & config.php), as well as the compiled views.
63
81
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.
65
87
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.
67
89
68
90
### Persistent Sessions in DataStore
69
91
@@ -72,4 +94,4 @@ We've included a session driver using DataStore for persistence, cached by memca
72
94
To make use of this, set:
73
95
-`SESSION_DRIVER=gae` in `.env`
74
96
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.
0 commit comments