axel-dzhurko/laravel-secret-env

以加密模式保存您的环境。

1.2 2021-11-22 14:13 UTC

This package is auto-updated.

Last update: 2024-09-22 20:13:59 UTC


README

您可以通过composer安装此包

composer require axel-dzhurko/laravel-secret-env

此包将自动注册自身。

您可以选择使用以下方式发布配置

php artisan vendor:publish --provider="LaravelSecretEnv\CredentialsServiceProvider" --tag="config"

Lumen安装

bootstrap/app中需要注册提供者

$app->register(\LaravelSecretEnv\CredentialsServiceProvider::class);

使用命令发布配置文件

cp vendor/axel-dzhurko/laravel-secret-env/config/credentials.php config/credentials.php

这是发布配置文件的内容

<?php

return [

    /*
     * Defines the file that will be used to store and retrieve the credentials.
     */
    'file' => config_path('credentials.php.enc'),

    /*
     * Defines the key that will be used to encrypt / decrypt the credentials.
     * The default is your application key. Be sure to keep this key secret!
     *
     * WARNING:: Need to use 1 of key option. Not used options must be 'null' or commented
     */
    'key' => config('app.key'),
    'key_file' => storage_path('cred.key'),

    'cipher' => config('app.cipher'),

    'editor' => env('EDITOR', 'nano')
];

注意:编辑应用程序必须安装在Docker镜像中或在系统纯安装情况下安装

生成密钥/密钥文件

php artisan credentials:key-generate

如果您使用 'config.key' - 您将获得配置的密钥字符串;如果您使用 'config.key_file' - 密钥文件将根据配置中的路径生成

用法

设置秘密变量

 php artisan credentials:edit

在代码中使用秘密

cred('some.var_name')

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件