ugiw/lumen-config-cache 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ugiw/lumen-config-cache

Composer 安装命令:

composer require ugiw/lumen-config-cache

包简介

Adds the Laravel command `php artisan config:cache` to Lumen

README 文档

README

Adds the Laravel artisan command config:cache to Lumen.

Once installed you can type php artisan lumen-config:cache in your console to gets all your Lumen configuration files loaded in the cache, which will increase your Lumen app response times.

Installation

This package can be used in Laravel lumen 7 or higher with PHP 7.0 or higher.

You can install the package via composer:

composer require ugiw/lumen-config-cache

Now register the service provider in bootstrap/app.php file:

$app->register(Ugiw\ConfigCache\ServiceProviders\ConfigCacheServiceProvider::class);

If you want to publish automatically the config file, you must install a package like lumen-vendor-publish, which contains a single command that enables you to publish a package config file to the config folder of your Lumen application.

So you can publish the config file like in Laravel:

php artisan vendor:publish --tag="lumen-config-cache"

If you dedice to not install any aditional package, then you can copy the file vendor/gipro/lumen-config-cache/src/config/config-cache.php to your app config folder.

This is the contents of the published config/config-cache.php config file:

return [

    /**
     * The name of the key where the config is stored in cache
     */
    'cache_key' => 'config_cache',

    /**
     * Expiration time for the config in cache
     */
    'cache_expiration_time' => 60*24, // One day

    /**
     * The config files (app, database, queue, etc.) to be cached
     * Add to this array whatever config files you want to load in cache
     */
    'config_files' => [
        'app',
    ],

];

You should enable the use of facades in Lumen uncommenting the following line in your bootstrap/app.php file:

// $app->withFacades();

Usage

You can access your config keys with ConfigCache::get facade method:

use Ugiw\ConfigCache\Facades\ConfigCache;

...

$api_url = ConfigCache::get('app.URL');

Also you can force the cached config to be refreshed with ConfigCache::refresh facade method:

use Ugiw\ConfigCache\Facades\ConfigCache;

...

ConfigCache::refresh();

You can use the artisan command lumen-config:cache to force the cached configuration to be refreshed too.

TIP: Add this command to your deployment script to be sure you have the last config cached after deploy your new app release:

php artisan lumen-config:cache

统计信息

  • 总下载量: 5.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固