mingalevme/lumen-maintaince

Lumen 中的维护模式支持

dev-master 2017-10-04 09:25 UTC

This package is auto-updated.

Last update: 2024-09-08 02:00:31 UTC


README

为 Lumen 框架提供维护模式的支撑。

安装

  1. composer require mingalevme/lumen-maintaince.
  2. 注册服务提供者 Mingalevme\Lumen\Maintaince\MaintainceServiceProvider
  3. Lumen 应用程序 类替换为以下之一:3.1. 你可以直接在 /bootstrap/app.php 中使用类 Mingalevme\Lumen\Maintaince\Application 而不是 Laravel\Lumen\Application
<?php // /bootsrap/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 Mingalevme\Lumen\Maintaince\Application(
    realpath(__DIR__.'/../')
);

// ...

3.2. 或者 你可以为你的 应用程序 类使用特质 Mingalevme\Lumen\Maintaince\Maintaince

<?php // /app/Helpers/Laravel/Lumen/Application.php

namespace App\Helpers\Laravel\Lumen;

use Mingalevme\Lumen\Maintaince\Maintaince;

class Application extends \Laravel\Lumen\Application
{
    use Maintaince;
}
<?php // /bootsrap/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 App\Helpers\Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

// ...
  1. 现在你可以使用 artisan downartisan up 命令了
$ php artisan list
# ...
Available commands:
    # ...
    down                Put the application into maintenance mode
    up                  Bring the application out of maintenance mode
    # ...
# ...
$ php artisan down
Application is now in maintenance mode.
$ php artisan up
Application is now live.