定制 dima-bzz/laravel-config-writer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dima-bzz/laravel-config-writer

Composer 安装命令:

composer require dima-bzz/laravel-config-writer

包简介

Laravel provider to be able to rewrite configuration

README 文档

README

Latest Stable Version Tests GitHub Code Style Action Status Total Downloads

Write to Laravel Config files and maintain file integrity.

This library adds the ability to write to configuration files.

You can rewrite array values inside a basic configuration file that returns a single array definition (like a Laravel config file) whilst maintaining the file integrity, leaving comments and advanced settings intact.

The following value types are supported for writing: strings, integers, booleans and arrays.

Support

This provider is designed to be used in Laravel from 7.4 and 8.0 version.

Setup

Install through composer:

composer require "dima-bzz/laravel-config-writer"

Set a filename to use as default in the .env file:

...
CONFIG_WRITER=config
...

You can optionally publish the config file with:

php artisan vendor:publish --tag="config-writer"

After you've configured everything you should run the command artisan config:clear or artisan config:cache.

Introduction

The default is strict write mode. If you wish, you can change it in the configuration file:

...
strict => false
...

Or through the Facade:

use DimaBzz\LaravelConfigWriter\Facades\ConfigWriter
...
ConfigWriter::of([
    'item' => 'new value',
    'nested.config.item' => 'value',
    'arrayItem' => ['Single', 'Level', 'Array', 'Values'],
    'numberItem' => 3,
    'booleanItem' => true
])
->strictMode(false)
->write();
...

Usage the helper

This is the easiest way to write new data to the config file:

config_writer([
    'item' => 'new value',
    'nested.config.item' => 'value',
    'arrayItem' => ['Single', 'Level', 'Array', 'Values'],
    'numberItem' => 3,
    'booleanItem' => true
]);

Set another config file optional:

config_writer('config-writer', [
    'item' => 'new value',
    'nested.config.item' => 'value',
    'arrayItem' => ['Single', 'Level', 'Array', 'Values'],
    'numberItem' => 3,
    'booleanItem' => true
]);

Usage the Facade

You can write new data to the config file like this:

...
ConfigWriter::write([
    'item' => 'new value',
    'nested.config.item' => 'value',
    'arrayItem' => ['Single', 'Level', 'Array', 'Values'],
    'numberItem' => 3,
    'booleanItem' => true
]);
...

Also, you can set certain parameters:

...
ConfigWriter::of([
    'item' => 'new value',
    'nested.config.item' => 'value',
    'arrayItem' => ['Single', 'Level', 'Array', 'Values'],
    'numberItem' => 3,
    'booleanItem' => true
])
->config('config-writer')
->strictMode(false)
->write();
...

Events

DimaBzz\LaravelConfigWriter\Events\WriteSuccess

This event will be fired if writing to the configuration file was successful. It has the following public properties:

  • name: configuration file name

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security related issues, please email dimabzz@gmail.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固