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 1mo 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

24

—

LowBetter than 32% of packages

Maintenance44

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

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

442d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/252abfe2680ff07ec6e567de9c62288f57a05b7f42bc3d123c2114dd74b14ba3?d=identicon)[miladhspr](/maintainers/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

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

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