rezgui/laravel-source-encrypter

Laravel Source Encrypter 6 / 7 / 8 / 9 / 10 / 11

v1.0.4 2024-11-08 17:26 UTC

This package is auto-updated.

Last update: 2024-12-08 21:11:38 UTC


README

License Latest Stable Version CodeFactor PHP Version Require Total Downloads

This package encrypts your php code with phpBolt for Laravel and Lumen 6, 7, 8, 9, 10 , 11

Introduction

Many PHP developers need to protect their application source code before they distribute it to their customers and make it difficult for others to modify it without their permission.

  • There are couple of techniques to protect PHP source code:

    • Making the code difficult to read – which involves in minification & obfuscation

    • Encoding the source code.

  • There are list of commercial PHP encoders (Zend, ionCube, SourceGuardian, NuCoder, etc).

  • A free encoder called phpBolt saves you from buying commercial encoders. phpBolt helps to protect your PHP source code by encrypting and decrypting code using a key.

Benifits of Encoding

  • Anyone can reuse your PHP script to any web server or localhost. phpBolt will encrypt your source code with a key.
  • Advance Protection -- Generate a specific key for each customer.
  • Online Encryption -- Encrypt source code from online also possible.
  • Encrypt PHP source code and obfuscate the PHP source code.
  • Prevent your PHP product from the nulled world.

phpBolt encoder

  • The author doesn't care about issues! The author will help you only if you pay for that. (he cannot provide free support)
  • phpBolt loader is an extension used to load PHP files protected and encoded using PHP encoder.

Guide

  1. Download phpBolt extension for 64-bit System

    • In order to use phpBolt, you need to download loader extension. Look for bolt.so inside the corresponding platform folder. (extension)

    • Or, directly using following wget command:

      cd /tmp
      wget https://phpbolt.com/wp-content/uploads/2024/03/phpBolt-extension-1.0.5.zip
    • Then unzip the downloaded file using the unzip command and move into the decompressed folder.

    • This is a mandatory step. Because PHP engine needs to identify then functions bolt_encrypt and bolt_decrypt functions.

  2. Install bolt.so extension for PHP

    • There will be different phpBolt loader files for various PHP versions, you need to select the right phpBolt loader for your installed PHP version on your server.

    • Next, find the location of the extension directory for PHP version 8.2.25 (for example), it is where the phpBolt loader file will be installed. The specified directory from the output of this command:

      php -i | grep extension_dir
      # output:
      # extension_dir => /usr/lib/php/20220829 => /usr/lib/php/20220829
    • Copy bolt.so from the respective platform folder into the folder where all PHP extensions are stored. In my case, /usr/lib/php/20220829 was the folder that stores all PHP extensions.

  3. Configure phpBolt Loader for PHP

    • Find the php.ini file and add extension='/usr/lib/php/20220829/bolt.so' in php.ini file. Then restart your server. Please choose correct bolt.so file. bolt.so is diffrent for each version and OS.

    • Open php.ini as following: sudo nano /etc/php.ini

    • Add blot.so extension: extension='/absolute-path/bolt.so'

    • Note:

      You will be encrypting using CLI,
      then you have to add extension in: `/etc/php/8.2/cli/php.ini` file,
      and in: `php/8.2/apache2/php.ini` file to decode the source code.
      (**Don't forget to restart server**)
      idem for FPM
      
    • Remember to replace absolute-path with the path of the extension. In my case: extension='/usr/lib/php/20220829/bolt.so'

    • Now we need to restart the Apache, Nginx, or php-fpm web server for the phpBolt loaders to come into effect.

    • Now you have successfully setup bolt loader extension.

Protect Larave Source Code

  • It is based on phpBolt extension, it encrypts your php code with phpBolt.

  • To install and use it in your Laravel project, follow this guide Installation.

  • There is no way to encrypt blade files. (blade files are not real PHP files)

  • There is no way to decrypt the source code, the only one who will have the source code is you.

  • You may face some problems/issues when you use encryption commands:

    • failed to open stream: No such file or directory (just modify the Laravel-Source-Encrypter/src/SourceEncryptCommand.php file)

    • You may run the encryption command and everything went well, but you got an exception about .gitignore. You don't have to worry about that. Keep going and ignore that exception.

Installation Package

Step 1

Require the package with composer using the following command:

composer require --dev rezgui/laravel-source-encrypter

Step 2

For Laravel

The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

'providers' => [
    // ...
    \rezgui\LaravelSourceEncrypter\SourceEncryptServiceProvider::class,
];

For Lumen

Add this line of code under the Register Service Providers section of your bootstrap/app.php:

$app->register(\rezgui\LaravelSourceEncrypter\SourceEncryptServiceProvider::class);

Step 3 (Optional)

You can publish the config file with this following command:

php artisan vendor:publish --provider="rezgui\LaravelSourceEncrypter\SourceEncryptServiceProvider" --tag=config

Note: If you are using Lumen, you have to use this package.

Usage

Open terminal in project root and run this command:

php artisan encrypt-source

This command encrypts files and directories in config/source-encrypter.php file. Default values are app, database, routes.

The default destination directory is encrypted. You can change it in config/source-encrypter.php file.

Also the default encryption key length is 6. You can change it in config/source-encrypter.php file. 6 is the recommended key length.

This command has these optional options:

Usage Examples

Written with ♥ by Siavash Bamshadnia, and update with ♥ by Yacine REZGUI.

Please support me by staring this repository.