PHPackages                             re2bit/yii2-secrets - 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. re2bit/yii2-secrets

AbandonedArchivedYii2-extension

re2bit/yii2-secrets
===================

Secrets storage and extractor for Yii2

1.0.0-alpha.1.2(1y ago)03MITPHPPHP ^7|^8

Since Jun 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/re2bit/yii2-secrets)[ Packagist](https://packagist.org/packages/re2bit/yii2-secrets)[ RSS](/packages/re2bit-yii2-secrets/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

PHP 7.0 Compatible Secrets Management Library Yii Module
========================================================

[](#php-70-compatible-secrets-management-library-yii-module)

This Module offers a secure way to manage sensitive information, inspired by the Symfony Secrets feature. It's designed for PHP 7.0 compatibility, leveraging modern cryptography with the Sodium extension or `paragonie/sodium_compat`.

Requirements
------------

[](#requirements)

- PHP 7.0 or newer
- Sodium PHP extension or `paragonie/sodium_compat`
- Yii 2

### Setting Up

[](#setting-up)

1. **Install Dependencies**: Make sure the Sodium extension is enabled in your PHP environment, or install `paragonie/sodium_compat` if it isn't already.
2. **Configure Yii2 Application**: Modify your Yii2 application configuration to include the Secrets module. Here’s how you can set it up:

    - **Update Composer**: Ensure your `composer.json` file includes the necessary libraries and update your project dependencies:

        ```
        composer require paragonie/sodium_compat
        ```

        This will install the library required for compatibility with PHP 7.0 if you do not have the Sodium PHP extension.
    - **Modify Config Files**: In your Yii2 application config file (usually `config/main.php` or `config/web.php` for web applications), add the following configurations to integrate the Vault component which manages the secrets:

        ```
        'components' => [
            'cache' => [
                'class' => 'yii\caching\FileCache',
            ],
            'vault' => [
                'class' => 'Re2bit\Yii2Secrets\Vault',
            ],
        ],
        'container' => [
            'definitions' => [
                'Re2bit\Yii2Secrets\Vault' => [
                    'keysDir' => '@app/config/secrets', // adjust the path as needed
                ],
            ],
        ],
        ```
    - **Adjust Entry Points**: In the entry point of your application, such as `index.php` for web applications or `yii` script for console applications, initialize the Vault and ConfigDecryptAdapter:

        ```
        $vault = new Vault(['keysDir' => __DIR__ . '/config/secrets']);
        $configDecryptAdapter = new ConfigDecryptAdapter($vault);
        $configDecryptAdapter->parse($config);
        ```

This setup ensures that your Yii2 application securely manages secrets, leveraging modern cryptography standards, even if running under PHP 7.0.

### Using Secrets in Configuration

[](#using-secrets-in-configuration)

To include secrets in your configuration, use the `%vault(secretName)%` format. When the configuration is parsed, these placeholders will be replaced with their decrypted values.

Example:

```
$config = [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=mydatabase',
            'username' => '%vault(DB_USERNAME)%',
            'password' => '%vault(DB_PASSWORD)%',
        ],
    ],
];
```

In this example, `%vault(DB_USERNAME)%` and `%vault(DB_PASSWORD)%` will be replaced by their respective decrypted values during the configuration parsing process.

License
-------

[](#license)

This package is available under MIT.

Acknowledgments
---------------

[](#acknowledgments)

This library is based and inspired by the work of:

- Tobias Schultze
- Jérémy Derussé
- Nicolas Grekas

from the Symfony framework. It has been adapted for PHP 7.0 with a focus on using Sodium for encryption.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~8 days

Total

3

Last Release

690d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b02704260607382adb07b7a4737005d6fecae4f1a14d825e0d98864443e9df1c?d=identicon)[re2bit](/maintainers/re2bit)

---

Top Contributors

[![re2bit](https://avatars.githubusercontent.com/u/12475481?v=4)](https://github.com/re2bit "re2bit (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/re2bit-yii2-secrets/health.svg)

```
[![Health](https://phpackages.com/badges/re2bit-yii2-secrets/health.svg)](https://phpackages.com/packages/re2bit-yii2-secrets)
```

PHPackages © 2026

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