Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Encryptor Bundle Laravel Package

nmure/encryptor-bundle

A Symfony bundle that provides encryption and decryption services for securing sensitive data in your applications. Integrates with Symfony's service container to make encrypting values, files, or configuration straightforward within your project.

View on GitHub
Deep Wiki
Context7

Getting Started

First, confront the mismatch: this is a Symfony Bundle, not a Laravel package. There is no service provider, no auto-discovery, and no facade. If you install nmure/encryptor-bundle in a Laravel app, you get a package whose DependencyInjection\EncryptorExtension and Bundle base class expect a Symfony kernel — Laravel will never boot it. The only useful thing here for a Laravel developer is the underlying library it wraps: nmure/encryptor, a thin OpenSSL wrapper with encrypt($string) / decrypt($cipher) methods.

Minimal path if you actually need it:

  1. composer require nmure/encryptor — not the bundle.
  2. Read vendor/nmure/encryptor/src/Nmure/Encryptor/Encryptor.php first — it's ~100 lines. That is the whole feature set.
  3. Confirm your PHP version can even install it. The last release was 2017-12-02; the composer constraint likely caps at PHP 7.x, so on PHP 8.1+ you'll hit install conflicts unless you use --ignore-platform-reqs (don't, in prod).
  4. First use case worth evaluating: encrypting a single sensitive DB column (e.g., a stripe_token or api_secret on a users table) before persisting, then decrypting on read.

Before writing a single line of integration code, ask the real question: why not Laravel's built-in Crypt::encryptString()? Laravel already gives you AES-256-CBC + HMAC-SHA256 with key management wired to APP_KEY. The only defensible reason to reach for this package is cross-runtime interoperability: a legacy Symfony 3/4 app encrypts data, and a Laravel app must decrypt it (or vice versa). If that's not your situation, you're adding a 0-dependent, 6-year-abandoned dependency to solve a problem Laravel already solved better.

Implementation Patterns

Pattern 1 — Standalone library inside a Laravel service provider

Skip the bundle entirely and bind the underlying Encryptor in a custom service provider:

// app/Providers/EncryptorServiceProvider.php
use Nmure\Encryptor\Encryptor;

public function register(): void
{
    $this->app->singleton(Encryptor::class, function ($app) {
        return new Encryptor(
            config('encryptor.secret', $app['config']->get('app.key'))
        );
    });
}

Add config/encryptor.php returning ['secret' => env('ENCRYPTOR_SECRET')]. Prefer a separate secret from APP_KEY so rotating one doesn't invalidate the other's ciphertext.

Pattern 2 — Eloquent attribute cast (the pattern you'll actually live with)

Wrap it in a custom cast so encrypted columns stay encrypted across the whole app:

// app/Casts/NmureEncrypted.php
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Nmure\Encryptor\Encryptor;

class NmureEncrypted implements CastsAttributes
{
    public function get($model, $key, $value, $attributes)
    {
        return $value === null ? null : app(Encryptor::class)->decrypt($value);
    }

    public function set($model, $key, $value, $attributes)
    {
        return $value === null ? null : app(Encryptor::class)->encrypt($value);
    }
}

Usage:

protected $casts = ['api_secret' => NmureEncrypted::class];

Never put this cast on a column you also want to query/WHERE/ORDER BY — ciphertext is non-deterministic, so search breaks immediately. Encrypted columns are write-then-read-only.

Pattern 3 — Symfony ↔ Laravel interop (the only real justification)

If you have a Symfony service producing ciphertext consumed by Laravel:

  • Pull the exact same nmure/encryptor version on both sides (pin in composer, don't float).
  • Share the secret out-of-band (env var, Vault, parameter store) — never commit it.
  • Build a contract test in each repo that decrypts a hardcoded ciphertext fixture produced by the other app. This is the single most valuable piece of test code you'll write for this integration; it catches IV/base64 mismatches before they corrupt rows.

Pattern 4 — Queue payloads / config secrets

For things like encrypting a webhook signing secret in a settings table, the cast pattern is overkill — just call app(Encryptor::class)->encrypt($secret) at the boundary (a SettingsRepository::putSecret() method) and decrypt() in a single getter. Keep encryption calls at the persistence edge, not scattered through controllers.

Gotchas and Tips

It's abandoned — treat it as vendored code, not a dependency. No release since 2017, 0 dependents, 2 stars. That means: no security patches, PHP 8+ likely unsupported, and you are your own maintainer. Fork it into your org namespace if you need it long-term. Weigh this heavily against Crypt.

Do not assume it's wire-compatible with Laravel's Crypt. Both use OpenSSL AES, but they differ in payload structure (Laravel's serialized JSON envelope + base64 + MAC vs. this library's raw openssl_encrypt output/base64). You cannot Crypt::decrypt() a string from this library or vice versa. Any migration between them is a manual re-encryption job — which itself requires decrypting every row with the old tool first. Plan that migration before you have millions of rows.

Key management is entirely on you. Unlike Laravel's APP_KEY handling, there's no key rotation, no key versioning, no cipher config. Rotating the secret means decrypting every row with the old key and re-encrypting with the new one, in a maintenance window, with a backfill you have to write. Bake a key_version column into the table now if you anticipate rotation.

PHP version + OpenSSL mode traps. If you force-install on PHP 8.x, watch for:

  • openssl_* returning false silently (older code often casts to string, producing "" instead of throwing). Always check if ($plain === false).
  • Deprecated implicit nullable params, create_function, or mcrypt remnants that fatal on 8.x. Run one decrypt round-trip in staging before trusting prod.

The bundle's Symfony wiring is dead weight in Laravel — do not waste time trying to shoehorn NmureEncryptorBundle through a fake kernel or PackageManifest. Install the library, bind the class yourself, and move on.

Debugging decrypt failures: they almost always mean one of four things — (1) ciphertext was truncated by a VARCHAR(255) column (use TEXT/LONGTEXT), (2) the secret differs between environments (check the resolved env value, not the config file), (3) the value was double-encoded (base64-of-base64 from a bad copy/paste), or (4) a previous failed write stored "" (empty string) which decrypts to false/garbage. Add a null/empty guard before decrypting.

Extension points are minimal by design. The Encryptor class is basically a final utility — there's no cipher-strategy interface to swap. If you need AES-256-GCM (authenticated, no separate MAC) rather than CBC, you're better off writing a 30-line Crypt-based wrapper than fighting this library.

Strong recommendation: unless a cross-runtime Symfony contract forces your hand, use Crypt::encryptString() / decryptString() for new code and reserve this package only for reading legacy data — behind a repository method you can later delete wholesale during a re-encryption migration.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager