Encrypt your Laravel source code and protect your intellectual property. Converts your PHP files into encrypted code that is decrypted only at runtime. No external extensions required.
Encrypt controllers, models, services, and routes. Your PHP files are compressed and encrypted using AES-256-CBC, and decrypted only at runtime via a custom autoloader.
Bundle all encrypted code into a single runtime file stored safely inside bootstrap cache. The original app/ directory is completely removed.
Works out of the box with standard PHP. No need to install and configure complex C extensions like ionCube on the target server.
Seamlessly detects and handles Composer and npm builds. Works automatically with API-only apps, Blade, Vue/React Starter Kits, and Vite projects.
composer require dev-reymark/laravel-source-encryptor
This command publishes the configuration file and securely generates and injects your SOURCE_ENCRYPTION_KEY into your .env file.
php artisan source:install
Run the build command to generate your encrypted distribution ready for deployment.
php artisan source:build
By default, the build runs npm install and npm run build if it detects assets. Use this flag to skip this step, which is ideal for API-only applications.
php artisan source:build --no-frontend
By default, the build runs composer install --no-dev inside the new dist/ directory. Use this flag to skip it if you are in a CI/CD pipeline or Docker environment where you prefer to handle Composer installation manually to utilize caching.
php artisan source:build --skip-composer
You can configure directory and file exclusions inside config/source-encryptor.php. Files and folders listed in the exclude array will be copied to your distribution normally without being encrypted.
'exclude' => [ // Do not remove 'bootstrap' or 'storage' — Laravel requires these. 'bootstrap', 'storage', // Add custom directories or files to exclude: 'app/Http/Controllers/Public', ],
A clean distribution folder is created at dist/. The original app/ directory is removed, and your source code is bundled.
dist/ ├ artisan ├ bootstrap/ │ └ cache/ │ ├ config.enc │ └ source.enc ├ composer.json ├ composer.lock ├ database/ ├ public/ ├ resources/ ├ routes/ ├ storage/ └ vendor/
PHP files are compressed and encrypted using robust AES-256-CBC encryption.
Encrypted code is bundled into a single file at bootstrap/cache/source.enc.
During execution, Laravel requests are passed through an EncryptedAutoloader.
SourceLoader decrypts and executes the PHP. Decrypted source never persists on disk.
SOURCE_ENCRYPTION_KEY absolutely private..env to version control.dist/ directory to production servers.