定制 rezgui/laravel-source-encrypter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rezgui/laravel-source-encrypter

Composer 安装命令:

composer require rezgui/laravel-source-encrypter

包简介

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

README 文档

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:

Option Description Example
source Path(s) to encrypt app,routes,public/a.php
destination Destination directory encrypted
keylength Encryption key length 6
force Force the operation to run when destination directory already exists

Usage Examples

Command Description
php artisan encrypt-source Encrypts with default source, destination and keylength. If the destination directory exists, asks for delete it.
php artisan encrypt-source --force Encrypts with default source, destination and keylength. If the destination directory exists, deletes it.
php artisan encrypt-source --source=app Encrypts app directory to the default destination with default keylength.
php artisan encrypt-source --destination=dist Encrypts with default source and key length to dist directory.
php artisan encrypt-source --destination=dist --keylength=8 Encrypts default source to dist directory and the encryption key length is 8.

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

Please support me by staring this repository.

rezgui/laravel-source-encrypter 适用场景与选型建议

rezgui/laravel-source-encrypter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 119 次下载、GitHub Stars 达 4, 最近一次更新时间为 2024 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「source」 「encryption」 「laravel」 「encrypt」 「encrypter」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rezgui/laravel-source-encrypter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rezgui/laravel-source-encrypter 我们能提供哪些服务?
定制开发 / 二次开发

基于 rezgui/laravel-source-encrypter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 119
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 140
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-07