PHPackages                             dev-reymark/laravel-source-encryptor - 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. dev-reymark/laravel-source-encryptor

ActiveLibrary[Security](/categories/security)

dev-reymark/laravel-source-encryptor
====================================

Encrypt Laravel source code for secure Laravel distribution

v1.1.1(1mo ago)148↓33.3%1MITPHPPHP ^7.2.5 || ^8.0CI passing

Since Mar 4Pushed 1mo agoCompare

[ Source](https://github.com/dev-reymark/laravel-source-encryptor)[ Packagist](https://packagist.org/packages/dev-reymark/laravel-source-encryptor)[ Docs](https://github.com/dev-reymark/laravel-source-encryptor)[ RSS](/packages/dev-reymark-laravel-source-encryptor/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (21)Used By (0)

Laravel Source Encryptor
========================

[](#laravel-source-encryptor)

[![Latest Version](https://camo.githubusercontent.com/7e535a469efee5e3d982b388f3620cc3a345cb642cb19af539d6b1cec096671b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465762d7265796d61726b2f6c61726176656c2d736f757263652d656e63727970746f722e737667)](https://packagist.org/packages/dev-reymark/laravel-source-encryptor)[![Total Downloads](https://camo.githubusercontent.com/31b590eca0ea053615215c19a0fd0bfc8b4de3581a62466dbf15cd49526d3835/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465762d7265796d61726b2f6c61726176656c2d736f757263652d656e63727970746f722e737667)](https://packagist.org/packages/dev-reymark/laravel-source-encryptor)[![License](https://camo.githubusercontent.com/b7fe0bc184fc43a591bf191157172939451a7251fb554641804b2131ddc49f9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465762d7265796d61726b2f6c61726176656c2d736f757263652d656e63727970746f722e737667)](https://packagist.org/packages/dev-reymark/laravel-source-encryptor)[![Laravel](https://camo.githubusercontent.com/de186db88ce28cb83f10c0afd987a4859293daa6d4db6cb16340d88140343260/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d372e785f2d2d5f31332e782d7265642e737667)](https://laravel.com)[![Tests](https://github.com/dev-reymark/laravel-source-encryptor/actions/workflows/run-tests.yml/badge.svg)](https://github.com/dev-reymark/laravel-source-encryptor/actions/workflows/run-tests.yml)

Encrypt Laravel source code and safely distribute applications **without exposing PHP source files**. Converts your Laravel application's PHP files into encrypted code that is decrypted only at runtime, allowing you to distribute Laravel applications while protecting your intellectual property.

Features
--------

[](#features)

- Encrypt controllers, models, services, and routes
- Bundle encrypted code into a single runtime file
- Runtime decryption via custom autoloader
- Automatic Composer and npm build handling
- Cross-platform (Windows, Linux, macOS)
- Laravel 7.x through 13.x support
- Optimized distribution builds
- No external PHP extensions required

Quick Installation
------------------

[](#quick-installation)

```
composer require dev-reymark/laravel-source-encryptor
php artisan source:install
```

The `source:install` command will automatically publish the configuration file and securely generate and inject a `SOURCE_ENCRYPTION_KEY` into your `.env` file.

Usage
-----

[](#usage)

### Build Production Distribution

[](#build-production-distribution)

```
php artisan source:build
```

The command will:

1. Installs Composer dependencies (--no-dev)
2. Installs npm dependencies if needed
3. Builds frontend assets (Vite / React / Vue)
4. Encrypts Laravel source files
5. Bundles encrypted code into a runtime file
6. Removes the original app/ directory
7. Generates encrypted route loaders
8. Create a clean **distribution folder** at `dist/`

Distribution Structure
----------------------

[](#distribution-structure)

```
dist/
 ├ artisan
 ├ bootstrap/
 │   └ cache/
 │       ├ config.enc
 │       └ source.enc
 ├ composer.json
 ├ composer.lock
 ├ database/
 ├ public/
 ├ resources/
 ├ routes/
 ├ storage/
 └ vendor/

```

The original `app/` directory is removed. All encrypted source code is stored inside `bootstrap/cache/source.enc`.

Build Options
-------------

[](#build-options)

Skip frontend build:

```
php artisan source:build --no-frontend
```

By default, the build command will automatically attempt to run `npm install` and `npm run build` if it detects frontend assets. Use the `--no-frontend` flag to skip this process entirely. This is highly recommended for API-only applications or if you compile your frontend assets separately.

Skip composer install:

```
php artisan source:build --skip-composer
```

By default, the build command automatically runs `composer install --no-dev` inside the new `dist/` directory. Use the `--skip-composer` flag to skip this step if you are running the build in a CI/CD pipeline or Docker environment where you prefer to handle Composer installation manually to utilize caching and speed up build times.

Configuration
-------------

[](#configuration)

You can customize the encryption behavior by modifying the `config/source-encryptor.php` file.

### Excluding Directories from Encryption

[](#excluding-directories-from-encryption)

If you have specific directories (or files) that you want to exclude from the encryption process (for example, if they need to be readable by third-party packages or contain specific assets), you can add them to the `exclude` array:

```
    'exclude' => [
        // Do not remove 'bootstrap' or 'storage' — Laravel requires these to remain as physical, unencrypted files.
        'bootstrap',
        'storage',
        // Add your own custom directories or files to exclude here:
        'app/Http/Controllers/Public',
    ],
```

Any files inside these excluded paths will be copied over to the `dist` directory exactly as they are, without being encrypted.

Running the Encrypted Application
---------------------------------

[](#running-the-encrypted-application)

```
cd dist
php artisan serve
```

Laravel automatically loads encrypted classes through the runtime loader.

How It Works
------------

[](#how-it-works)

1. PHP files are compressed and encrypted using **AES-256-CBC**
2. Encrypted code is bundled into `bootstrap/cache/source.enc`
3. During runtime: Autoload request → EncryptedAutoloader → SourceLoader decrypts → PHP executes
4. Decrypted source **never persists on disk**

Frontend Support
----------------

[](#frontend-support)

The build system automatically detects frontend environments:

EnvironmentBehaviorAPI-only LaravelSkips frontend buildLaravel + BladeSkips if no build scriptVue Starter KitRuns `npm install` + `npm run build`React Starter KitRuns `npm install` + `npm run build`Vite ProjectsFully supportedRequirements
------------

[](#requirements)

- PHP **7.2.5+**
- Laravel **7.x - 13.x**
- OpenSSL extension enabled
- Composer

Security Notes
--------------

[](#security-notes)

- Keep your `SOURCE_ENCRYPTION_KEY` private
- Never commit `.env` to version control
- Only distribute the `dist/` directory

License
-------

[](#license)

MIT License

Author
------

[](#author)

**Rey Mark Tapar**

[Website](https://reymarktapar.vercel.app) | [GitHub](https://github.com/dev-reymark/laravel-source-encryptor)

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

Recently: every ~0 days

Total

20

Last Release

44d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.1.0PHP ^7.2.5 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/139051128?v=4)[Rey Mark Tapar](/maintainers/dev-reymark)[@dev-reymark](https://github.com/dev-reymark)

---

Top Contributors

[![dev-reymark](https://avatars.githubusercontent.com/u/139051128?v=4)](https://github.com/dev-reymark "dev-reymark (39 commits)")

---

Tags

laravelencryptionlaravel-packagecode-protectionsource-protection

### Embed Badge

![Health badge](/badges/dev-reymark-laravel-source-encryptor/health.svg)

```
[![Health](https://phpackages.com/badges/dev-reymark-laravel-source-encryptor/health.svg)](https://phpackages.com/packages/dev-reymark-laravel-source-encryptor)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)

PHPackages © 2026

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