a1comms / gae-support-laravel
Google App Engine 标准环境对 Laravel 应用程序的支持
Requires
- php: ^8.1
- a1comms/eloquent-datastore: ~1
- a1comms/eloquent-sqlcommenter: ~9
- a1comms/opencensus: ~0
- a1comms/opencensus-exporter-stackdriver: ~0
- google/cloud: >=0.175.0 <1.0.0
- guzzlehttp/guzzle: ^7.4.1
- illuminate/cache: ~9
- illuminate/collections: ~9
- illuminate/console: ~9
- illuminate/container: ~9
- illuminate/contracts: ~9
- illuminate/encryption: ~9
- illuminate/filesystem: ~9
- illuminate/http: ~9
- illuminate/queue: ~9
- illuminate/support: ~9
- illuminate/view: ~9
- kelvinmo/simplejwt: ^0.6.2
- xantios/mimey: ^2.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- phpmd/phpmd: @stable
Suggests
- a1comms/php-gds: Provides legacy Datastore support
- dev-php8.1-laravel9.x
- v9.0.42
- v9.0.41
- v9.0.40
- v9.0.39
- v9.0.38
- v9.0.37
- v9.0.36
- v9.0.35
- v9.0.34
- v9.0.33
- v9.0.32
- v9.0.31
- v9.0.30
- v9.0.29
- v9.0.28
- v9.0.27
- v9.0.26
- v9.0.25
- v9.0.24
- v9.0.23
- v9.0.22
- v9.0.21
- v9.0.20
- v9.0.19
- v9.0.18
- v9.0.17
- v9.0.16
- v9.0.15
- v9.0.14
- v9.0.13
- v9.0.12
- v9.0.11
- v9.0.10
- v9.0.9
- v9.0.8
- v9.0.7
- v9.0.6
- v9.0.5
- v9.0.4
- v9.0.3
- v9.0.2
- v9.0.1
- v6.0.41
- v6.0.39
- v6.0.38
- v6.0.37
- v6.0.36
- v6.0.35
- v6.0.34
- v6.0.33
- v6.0.32
- v6.0.31
- v6.0.30
- v6.0.29
- v6.0.28
- v6.0.27
- v6.0.26
- v6.0.25
- v6.0.24
- v6.0.23
- v6.0.22
- v6.0.21
- v6.0.20
- v6.0.19
- v6.0.18
- v6.0.17
- v6.0.16
- v6.0.15
- v6.0.14
- v6.0.13
- v6.0.12
- v6.0.11
- v6.0.10
- v6.0.9
- v6.0.8
- v6.0.7
- v6.0.6
- v6.0.5
- v6.0.4
- v6.0.3
- v6.0.2
- v6.0.1
- v5.5.49
- v5.5.48
- v5.5.47
- v5.5.46
- v5.5.45
- v5.5.44
- 5.5.43
- v5.5.42
- v5.5.41
- v5.5.40
- v5.5.39
- v5.5.38
- v5.5.37
- v5.5.36
- v5.5.35
- v5.5.34
- v5.5.33
- v5.5.32
- v5.5.31
- v5.5.30
- v5.5.29
- v5.5.28
- v5.5.27
- v5.5.26
- v5.5.25
- v5.5.24
- v5.5.23
- v5.5.22
- v5.5.21
- v5.5.20
- v5.5.19
- v5.5.18
- v5.5.17
- v5.5.16
- v5.5.15
- v5.5.14
- v5.5.13
- v5.5.12
- v5.5.11
- v5.5.10
- v5.5.9
- v5.5.8
- v5.5.7
- v5.5.6
- v5.5.5
- v5.5.4
- v5.5.3
- v5.5.2
- v5.5.1
- 5.1.27
- 5.1.26
- 5.1.25
- 5.1.24
- 5.1.23
- 5.1.22
- 5.1.21
- 5.1.20
- 5.1.19
- 5.1.18
- 5.1.17
- 5.1.16
- 5.1.15
- 5.1.14
- 5.1.13
- 5.1.12
- 5.1.11
- 5.1.10
- 5.1.9
- 5.1.8
- 5.1.7
- 5.1.6
- v5.1.5
- 5.1.4
- 5.1.3
- v5.1.2
- 5.1.1
- 5.1.0
- dev-php8.3-laravel11.x
- dev-error-reporting-exception-handling
- dev-php7.4-laravel6.0
- dev-php72-laravel55
- dev-php55-laravel51-compat
This package is auto-updated.
Last update: 2024-05-01 14:37:50 UTC
README
Google App Engine (GAE) 标准环境对 Laravel 9.x 的支持包。
基于 @shpasser 在 App Engine 标准环境(基于 PHP5.5 运行时)上的原始工作 https://github.com/shpasser/GaeSupportL5
注意:我们只打算支持 Laravel LTS 版本,此版本专门针对 Laravel 9.x
功能
- StackDriver 日志集成
- StackDriver 追踪集成(见 docs/trace.md)
- Blade 视图预编译器(可选,见 docs/blade-pre-compile.md)
- Guzzle 集成(可选,见 docs/trace.md)
- Laravel Auth 集成 IAP(可选,见 docs/iap-auth-verify.md)
- Cloud Tasks 队列驱动器(可选,见 docs/queue.md)
- 从 Git 通过 Cloud Build 部署的示例,以及使用 KMS 的加密秘密(可选,见 docs/cloudbuild.md)
安装
使用 Composer 引入包
"require": { "a1comms/gae-support-laravel": "~9.0" }
Laravel 特定(非 Lumen)
1. 在 composer.json
中添加以下内容
"scripts": { "post-autoload-dump": [ "php artisan gae:prepare" ] },
2. 对于 Laravel,在 config/app.php
中包含服务提供者
'providers' => [ A1comms\GaeSupportLaravel\GaeSupportServiceProvider::class, ];
3. 此外,为了增加功能,包括可选的服务提供者
'providers' => [ A1comms\GaeSupportLaravel\Auth\AuthServiceProvider::class, A1comms\GaeSupportLaravel\View\ViewServiceProvider::class, A1comms\GaeSupportLaravel\Queue\QueueServiceProvider::class, A1comms\GaeSupportLaravel\Trace\TraceServiceProvider::class, ];
并移除这些服务提供者所替代的相关 Laravel 服务提供者
'providers' => [ //Illuminate\View\ViewServiceProvider::class, //Illuminate\Queue\QueueServiceProvider::class, ];
4. 更新 bootstrap/app.php
以加载覆盖的应用程序类并初始化日志到 Stackdriver
/* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | The first thing we will do is create a new Laravel application instance | which serves as the "glue" for all the components of Laravel, and is | the IoC container for the system binding all of the various parts. | */ $app = new A1comms\GaeSupportLaravel\Foundation\Application( $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) );
5. 更新 app/Exceptions/Handler.php
以启用正确的异常日志到 StackDriver 错误报告和日志
更改以下 use
语句
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
到我们的类,这将注入所需的日志钩子
use A1comms\GaeSupportLaravel\Foundation\Exceptions\Handler as ExceptionHandler;
6. 在 config/logging.php
中,配置自定义记录器并将其设置为默认记录器
将紧急日志路径设置到 App Engine 会将其转发到 Stackdriver 日志的位置也是有用的,见下文。
<?php use A1comms\GaeSupportLaravel\Log\CreateLoggingDriver; return [ 'default' => 'gae', 'channels' => [ 'gae' => [ 'driver' => 'custom', 'via' => CreateLoggingDriver::class, ], 'emergency' => [ 'path' => '/var/log/emergency.log', ], ], ];
7. 在 .env
中,设置以下内容
QUEUE_CONNECTION=gae
CACHE_DRIVER=array
SESSION_DRIVER=gae
LOG_CHANNEL=gae
Lumen 特定(非 Laravel)
1. 更新 bootstrap/app.php
以加载覆盖的应用程序类
/* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | Here we will load the environment and create the application instance | that serves as the central piece of this framework. We'll use this | application as an "IoC" container and router for this framework. | */ $app = new A1comms\GaeSupportLaravel\Foundation\LumenApplication( $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) );
2. 更新 app/Exceptions/Handler.php
以启用正确的异常日志到 StackDriver 错误报告和日志
更改以下 use
语句
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
到我们的类,这将注入所需的日志钩子
use A1comms\GaeSupportLaravel\Foundation\Exceptions\LumenHandler as ExceptionHandler;
升级(从 Laravel/Lumen 6.x LTS)
Laravel 特定(非 Lumen)
1. 在 composer.json
中更新包版本
"require": { "a1comms/gae-support-laravel": "~9.0" }
2. 遵循所有 6.x ... 9.x 版本的 Laravel 升级步骤
Lumen 特定(非 Laravel)
1. 在 composer.json
中更新包版本
"require": { "a1comms/gae-support-laravel": "~9.0" }
2. 遵循所有 6.x ... 9.x 版本的 Lumen 升级步骤