PHPackages                             miladhspr/laravel-encryptable - 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. [Security](/categories/security)
4. /
5. miladhspr/laravel-encryptable

ActiveLibrary[Security](/categories/security)

miladhspr/laravel-encryptable
=============================

Laravel automatic attribute encryption

v0.0.4(1y ago)0102MITPHP

Since Feb 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/miladhspr/laravel-encryptable)[ Packagist](https://packagist.org/packages/miladhspr/laravel-encryptable)[ RSS](/packages/miladhspr-laravel-encryptable/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (5)Used By (0)

Laravel Encryptable Package
===========================

[](#laravel-encryptable-package)

Overview
--------

[](#overview)

`laravel-encryptable` is a package that provides automatic encryption and decryption of model attributes in Laravel applications. This ensures that sensitive data is stored in an encrypted format in the database and is automatically decrypted when accessed within your application.

Features
--------

[](#features)

- **Automatic Encryption and Decryption**: Automatically encrypts and decrypts specified attributes when interacting with your models.
- **Customizable**: You can define which attributes should be encrypted using the `$encryptable` property on the model.
- **Transparent for Queries**: Queries like `where`, `whereHas`, `orWhere`, etc., work seamlessly with encrypted attributes.
- **Secure**: Data is encrypted using the key defined in your `.env` file, ensuring that only your application can access it.

Installation
------------

[](#installation)

### 1. Install the Package

[](#1-install-the-package)

Run the following command to install the package via Composer:

```
composer require miladhspr/laravel-encryptable
```

### 2. Publish the Configuration (Optional)

[](#2-publish-the-configuration-optional)

You can publish the package's config file with the following command:

```
php artisan vendor:publish --provider="Miladhspr\LaravelEncryptable\EncryptableServiceProvider"
```

### 3. Enable/Disable Encryption

[](#3-enabledisable-encryption)

Set `ENCRYPTION_ENABLED=true` or `ENCRYPTION_ENABLED=false` in your .env file to enable or disable encryption globally.

### 4. Define Encrypted Attributes in Your Model

[](#4-define-encrypted-attributes-in-your-model)

Use the Encryptable trait in your model and specify the $encryptable attribute for fields to be encrypted:

```
namespace App\Models;
use Miladhspr\LaravelEncryptable\Traits\Encryptable;

class User extends Model
{
    use Encryptable;

    protected $encryptable = ['email', 'phone_number'];
}
```

Usage
-----

[](#usage)

### Inserting/Updating Data

[](#insertingupdating-data)

When inserting or updating records, specified attributes in $encryptable are automatically encrypted:

```
User::create([
    'name' => 'John Doe',
    'email' => 'john.doe@example.com',
    'phone_number' => '1234567890',
]);

```

###  Health Score

23

—

LowBetter than 25% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

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 ~0 days

Total

4

Last Release

543d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32781251?v=4)[milad hassan pour](/maintainers/miladhspr)[@miladhspr](https://github.com/miladhspr)

---

Top Contributors

[![miladhspr](https://avatars.githubusercontent.com/u/32781251?v=4)](https://github.com/miladhspr "miladhspr (6 commits)")

### Embed Badge

![Health badge](/badges/miladhspr-laravel-encryptable/health.svg)

```
[![Health](https://phpackages.com/badges/miladhspr-laravel-encryptable/health.svg)](https://phpackages.com/packages/miladhspr-laravel-encryptable)
```

###  Alternatives

[phpids/phpids

PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application

791150.0k2](/packages/phpids-phpids)[paragonie/ecc

PHP Elliptic Curve Cryptography library

25866.3k44](/packages/paragonie-ecc)[nicobleiler/php-passphrase

Passphrase generator with Laravel integration, inspired by Bitwarden. Uses the EFF long word list by default with support for custom wordlists.

4912.6k](/packages/nicobleiler-php-passphrase)[dwgebler/encryption

Encryption wrapper for PHP using libsodium — simple API for symmetric and asymmetric encryption, password hashing, digital signing, and message authentication.

317.5k](/packages/dwgebler-encryption)

PHPackages © 2026

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