hubchain/gae-support-laravel

为 Laravel 应用程序提供 Google App Engine (标准环境和灵活环境) 运行时支持。


README

Laravel 5.5 LTS 提供的 Google App Engine (GAE) 标准环境和灵活环境支持包。

Latest Stable Version Monthly Downloads Total Downloads Latest Unstable Version License

基于 @shpasser 在 App Engine 标准环境(PHP5.5 运行时)上的原始工作 https://github.com/shpasser/GaeSupportL5

此库旨在实现标准环境和灵活环境之间的同构操作。

注意:我们只打算支持 Laravel LTS 版本,本版本特别针对 Laravel 5.5 LTS

功能

安装

通过 Composer 引入此包。

"require": {
    "a1comms/gae-support-laravel": "~5.5"
}

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(
    realpath(__DIR__.'/../')
);

/*
|--------------------------------------------------------------------------
| Setup Early Logging
|--------------------------------------------------------------------------
*/
A1comms\GaeSupportLaravel\Log\Logger::setup($app);

5. 更新 app/Exceptions/Handler.php 以启用适当的异常记录到 StackDriver 错误报告和日志

更改以下 use 语句

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

到我们的类,它将注入所需的日志钩子

use A1comms\GaeSupportLaravel\Foundation\Exceptions\Handler as ExceptionHandler;

6..env 中设置以下内容

QUEUE_DRIVER=gae
CACHE_DRIVER=array
SESSION_DRIVER=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(
    realpath(__DIR__.'/../')
);

2. 更新 app/Exceptions/Handler.php 以启用适当的异常记录到 StackDriver 错误报告和日志

更改以下 use 语句

use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;

到我们的类,它将注入所需的日志钩子

use A1comms\GaeSupportLaravel\Foundation\Exceptions\LumenHandler as ExceptionHandler;