innoboxrr/laravel-env-editor

一个支持 .Env 文件、编辑和备份的 Laravel 扩展包

1.0.0 2024-08-25 05:00 UTC

This package is auto-updated.

Last update: 2024-08-25 05:00:27 UTC


README

Latest Version on Packagist Total Downloads Coverage Status Codacy Badge Maintainability License

Laravel .env 编辑器(带图形界面)

此扩展包允许动态管理 Laravel .env 文件中的值(添加、编辑、删除键),上传另一个 .env 文件或创建备份
管理可以通过用户界面进行,或者通过使用 EnvEditor 面具以编程方式进行,而不会破坏文件结构。
此扩展包的灵感来源于 Brotzka/laravel-dotenv-editor

安装

  1. 安装扩展包

    composer require innoboxrr/laravel-env-editor
  2. 发布资源

    php artisan vendor:publish --provider=Innoboxrr\EnvEditor\ServiceProvider     

    这将发布所有文件

    • config -> env-editor.php
    • views -> resources/views/vendor/env-editor/..
    • lang -> resources/lang/vendor/env-editor.php

    或发布特定标签

     //Publish specific tag
     php artisan vendor:publish --tag=config
     php artisan vendor:publish --tag=translations
     php artisan vendor:publish --tag=views
     
     //Publish specific Tag from this Vendor
     php artisan vendor:publish --provider=Innoboxrr\EnvEditor\ServiceProvider --tag=config  
    

可用方法

  • getEnvFileContent
  • keyExists
  • getKey
  • addKey
  • editKey
  • deleteKey
  • getAllBackUps
  • upload
  • backUpCurrent
  • getFilePath
  • deleteBackup
  • restoreBackUp
示例
  
 EnvEditor::getEnvFileContent($fileName='') 
 // Return The .env Data as Collection.
 // If FileName Is provided it searches inside backups Directory and returns these results

 EnvEditor::keyExists($key)
 // Search key existance in .env
 
 EnvEditor::getKey(string $key, $default = null)    
 // Get key value from .env,

  EnvEditor::addKey($key, $value, array $options = [])
  // Adds new Key in .env file
  // As options can pass ['index'=>'someNumericIndex'] in order to place the new key after an other and not in the end,
  // or ['group'=>'MAIL/APP etc'] to place the new key oat the end of the group 

  EnvEditor::editKey($key, $value)
  // Edits existing key value

  EnvEditor::deleteKey($key)    

  EnvEditor::getAllBackUps()
  // Returns all Backup files as collection with some info like, created_date, content etc.

  EnvEditor::upload(UploadedFile $uploadedFile, $replaceCurrentEnv)
  // Gets an UploadedFile and stores it as backup or as current .env

  EnvEditor::backUpCurrent()
  // Backups current .env

  EnvEditor::getFilePath($fileName = '')
  // Returns the full path of a backup file. 
  // If $fileName is empty returns the full path of the .env file

  EnvEditor::deleteBackup($fileName)
  

  EnvEditor::restoreBackUp()
  

用户界面

注意:默认情况下禁用了用户界面。您可以通过更改配置选项 env-editor.route.enable 来启用它。

用户界面包含三个标签页


当前 .env

Overview

添加新键

AddKey

编辑键

EditKey

删除键

DeleteKey

备份

备份索引

Overview

备份文件详细信息

Overview

上传

Overview