eureciclo / gae-support-laravel
为 Laravel 应用程序提供 Google App Engine (标准环境和灵活环境) 运行时支持。
Requires
- php: ^8.3
- a1comms/eloquent-datastore: ~11
- a1comms/eloquent-sqlcommenter: ~11
- a1comms/opencensus: ~0
- a1comms/opencensus-exporter-stackdriver: ~0
- firebase/php-jwt: ^6.3
- google/cloud: >=0.175.0 <1.0.0
- guzzlehttp/guzzle: ^7.4.1
- illuminate/cache: ~11
- illuminate/collections: ~11
- illuminate/console: ~11
- illuminate/container: ~11
- illuminate/contracts: ~11
- illuminate/encryption: ~11
- illuminate/filesystem: ~11
- illuminate/http: ~11
- illuminate/queue: ~11
- illuminate/support: ~11
- illuminate/view: ~11
- symfony/console: ^7.0
- xantios/mimey: ^2.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- phpmd/phpmd: @stable
Suggests
- a1comms/php-gds: Provides legacy Datastore support
- dev-dev-master
- v10.0.1
- v10.0.0
- 5.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-update-php-8-3
- dev-new-master
- dev-bugfix-undefined-var
- dev-php72-laravel55
- dev-php7.3-laravel6.0
- dev-iamacarpet/pushtask-timestamp-fix
- dev-master
- dev-php55-laravel51-compat
This package is not auto-updated.
Last update: 2024-09-20 11:38:56 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 部署示例,包括使用 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. 遵循 Laravel 升级步骤,适用于所有 6.x ... 9.x 版本
Lumen 特定(非 Laravel)
1. 在 composer.json
中更新包版本
"require": { "a1comms/gae-support-laravel": "~9.0" }
2. 遵循 Lumen 升级步骤,适用于所有 6.x ... 9.x 版本