PHPackages                             litermi/laravel-secrets-driver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. litermi/laravel-secrets-driver

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

litermi/laravel-secrets-driver
==============================

Easy data retrieval from AWS Secrets Manager API and beyond

01.1k1PHP

Since Nov 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/litermi/laravel-secrets-driver)[ Packagist](https://packagist.org/packages/litermi/laravel-secrets-driver)[ RSS](/packages/litermi-laravel-secrets-driver/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Secrets Driver for Litermi Laravel Projects
===========================================

[](#secrets-driver-for-litermi-laravel-projects)

Features
--------

[](#features)

- Reusable trait
- Ready-to-go database configuration.
- Support for custom secrets managers.
- Overridable configuration.

Install
-------

[](#install)

### Composer install

[](#composer-install)

```
composer require litermi/laravel-secrets-driver
```

### Configure your project's tag

[](#configure-your-projects-tag)

By default, the package takes the application's name and creates a tag using Laravel's `Str::slug()`. If there's no name assigned, the tag will be `"litermi-project"`. In case this needs to be overriden, the environmental variable `SECRETS_DRIVER_PROJECT_TAG` can be changed to provide a new value. If the new tag is not a proper slug, it will be converted to one.

### Create secrets in the Secrets Manager

[](#create-secrets-in-the-secrets-manager)

The default naming convention is: `//`

In case this needs to be changed, the environmental variable `SECRETS_DRIVER_NAME_FORMAT` can be changed to provide a new format using a literal (string delimited by single quotes: `'`) using the values `$key`, `$project` and `$env`. The default value is `'$env/$project/$key'`.

**Ex.: stage/blog/tpps\_mysql**

Sometimes, the environment production tag can be different on different setups (ex.: `prod`, `production`, `produccion`, `producción`...); to normalize to a single value, the environmental variable `SECRETS_DRIVER_PRODUCTION_TAG` can be changed to a single one. If this environmental variable is set as empty, the production tag will be the same as `APP_ENV`. The default value is `"prod"`, so a typical production key would be searched in the provider as `prod//`.

#### AWS Secrets Manager

[](#aws-secrets-manager)

By default, the package is configured to work with the AWS Secrets Manager. To use it, configure Laravel's common AWS environmental variables in the `.env` file and create the secrets using the stated convention. You can use either key/value pairs or a JSON string.

#### Custom Secrets Manager

[](#custom-secrets-manager)

To select a secrets manager, the environmental variable `SECRETS_DRIVER_MANAGER` can be changed to provide a new value; this value can be a full classname or a string that can be made a StudlyCase prefix for a classname (either on `Litermi\SecretsDriver\Managers\SecretsManager` or a local equivalent on `App\SecretsDriver\Managers\SecretsManager`). Whatever the case, the target class must implement the `Litermi\SecretsDriver\Managers\Interfaces\ManagesSecrets` interface. The default value is `"aws"`.

Trait usage
-----------

[](#trait-usage)

To retrieve secrets within any object, make its class use the `Litermi\SecretsDriver\Traits\HasRemoteSecrets` trait; then, retrieve the secret by its name using the `$this->getSecret()` method:

```
    /* Environment: stage; Project tag: trllnhelp */

    use Illuminate\Support\ServiceProvider;
    use Litermi\SecretsDriver\Traits\HasRemoteSecrets;

    class TppsConfigProvider extends ServiceProvider
    {
        /* Trait included! */
        use HasRemoteSecrets;

        public function boot()
        {
            /**
             * New configuration data for the sent secret
             *
             * This will look for secret "stage/trllnhelp/tpps",
             * which is a JSON string that represents an object
             * with properties.
             *
             * If the secret is not found, it'll return
             * an empty array and log an incidence.
             *
             * @var mixed[]
             */
            $tppsData = $this->getSecret("tpps");

            /* Example: rewrite configuration */
            foreach ($tppsData as $key => $value) {
                /* Change the data */
                config([
                    "tpps.{$key}" => $value,
                ]);
            }
        }

        public function register()
        {
            //
        }
    }
```

The `$this->getSecret()` method accepts a single parameter: a string or an array of strings. If the parameter is an array, it'll return a keyed array, with the keys being the secrets' names.

Trait customization
-------------------

[](#trait-customization)

In case the trait's methods need to be changed (for example, to make a specific configuration override that must not be project-wide), include a method override in the class that uses the trait. Refer to the trait's code to know which method to override.

```
    use Litermi\SecretsDriver\Traits\HasRemoteSecrets;

    class PaywayRepository
    {
        /* Trait included! */
        use HasRemoteSecrets;

        /**
         * Protected method to get the cache key prefix
         *
         * Override of HasRemoteSecrets::getCacheKeyPrefix()
         *
         * @return  string            The prefix
         */
        protected function getCacheKeyPrefix()
        {
            return "payway-data";
        }

        /**
         * Protected method to get the time interval for regular cache
         *
         * Override of HasRemoteSecrets::getCacheInterval()
         *
         * @return string Time interval
         */
        protected function getCacheInterval()
        {
            return "15s";
        }
        ...
    }
```

Database configuration retrieval
--------------------------------

[](#database-configuration-retrieval)

In case database credentials need to be taken from the remote manager, add the `use_secrets_driver` key to the connection's configuration inside the `config/database.php` file and set it to `true`:

```
    ...

    'connections' => [

        'mysql' => [
            ...
            'use_secrets_driver' => true,
        ],
        ...
```

If the current environment is set as `local`, database credentials will be the same as in Laravel's `.env` file, to allow usage of the local database for testing and configuration; otherwise, when on a non-local environment, any connection that has the property `use_secrets_driver` set as `true` will be looked for in the remote secrets manager, using the name convention and the connection name as the secret's name:

**Ex.: stage/blog/mysql**

There is no minimum database configuration needed to be saved in the secret; however, it is recommended that these variables be provided (values are examples):

```
{
  "database": "blog_database",
  "driver": "mysql",
  "host": "127.0.0.1",
  "password": "*******",
  "port": "3306",
  "username": "mysql_user",
  "charset": "utf8mb4",
  "collation": "utf8mb4_unicode_ci"
}
```

Cache configuration
-------------------

[](#cache-configuration)

The package uses the project's cache driver and sets different durations for different cache values. The following block shows the environmental variables and their defaults. If these variables are not present, these defaults will still apply.

```
    SECRETS_DRIVER_CACHE_INTERVAL="30s"
    SECRETS_DRIVER_CACHE_BACKUP_INTERVAL="12h"
    SECRETS_DRIVER_CACHE_NOTIFICATION_INTERVAL="10s"
```

Configuration publishing
------------------------

[](#configuration-publishing)

If further configuration needs to be changed, it's possible to publish the configuration to the project's `config` directory:

```
php artisan vendor:publish --tag=secrets-driver-config
```

License
-------

[](#license)

Litermi Secrets Driver for Laravel is released under the MIT Licence. See the bundled [LICENSE](https://github.com/litermi/laravel-secrets-driver/blob/master/LICENSE.md) file for details.

Acknowledgements
----------------

[](#acknowledgements)

This package is heavily influenced by the previous work made in [litermi/aws-secret-dbdriver](https://github.com/litermi/aws-secret-dbdriver), authored by Diego Cotelo ().

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/73536c3820a8a906ec83b9a56ebff32aa6ef4529c66efb6a33b42fde1dfb55f2?d=identicon)[litermi](/maintainers/litermi)

---

Top Contributors

[![JoaquinHeredia](https://avatars.githubusercontent.com/u/183531564?v=4)](https://github.com/JoaquinHeredia "JoaquinHeredia (1 commits)")[![litermi-owner](https://avatars.githubusercontent.com/u/56643809?v=4)](https://github.com/litermi-owner "litermi-owner (1 commits)")

### Embed Badge

![Health badge](/badges/litermi-laravel-secrets-driver/health.svg)

```
[![Health](https://phpackages.com/badges/litermi-laravel-secrets-driver/health.svg)](https://phpackages.com/packages/litermi-laravel-secrets-driver)
```

###  Alternatives

[robinvdvleuten/ulid

Universally Unique Lexicographically Sortable Identifier (ULID) implementation for PHP.

4573.9M31](/packages/robinvdvleuten-ulid)[flagception/flagception-bundle

Feature toggle bundle on steroids.

294.0M](/packages/flagception-flagception-bundle)[ecommpro/module-custom-currency

Custom Currency for Magento 2

194.2k](/packages/ecommpro-module-custom-currency)[oxid-esales/vcms-examples

This module contains examples for vcmsmodule.

161.8k](/packages/oxid-esales-vcms-examples)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
