🔒 DEVELOPER DOCUMENTATION

How to Encode & Protect PHP Code

Learn how to use native phpcube extension functions to encrypt your PHP scripts directly from the Linux CLI or Composer pipeline.

Encoding in three steps

1

Active phpcube Loader

The phpcube.so extension must be active in your PHP CLI environment. Verify by running:

php -m | grep phpcube
2

Authorized license.lic

Place your signed license.lic file in your project root. The encoder extracts the unique product_key to encrypt your files.

ls -la license.lic
3

Run 1-Line Command

Execute your chosen encoding command below. Files are encrypted instantly with military-grade AES-256 + HMAC-SHA256.

php -r "phpcube_encode_dir('app');"

Encoding Methods & Command Reference

Select a method below to view the exact PHP CLI command for your workflow:

A. In-Place Directory Encoding

Encrypts all PHP files inside app/ and overwrites them with encrypted bytecode:

php -r "phpcube_encode_dir('app');"

B. Safe Target Output Directory (Recommended)

Preserves your original clean source code in app/ and outputs protected files into dist/app/:

php -r "phpcube_encode_dir('app', null, 'dist/app');"

Visual Code Transformation

Compare plain PHP source code before and after encryption by phpcube:

❌ Before (Plain Source Code — Vulnerable to Theft) Plain PHP
<?php
namespace App\Services;

class PaymentGateway {
    // Plaintext business logic exposed!
    public function verifyClient($license) {
        return ($license->status === 'active');
    }
}
✓ After (phpcube Encrypted — 100% Protected) Encrypted Bytecode
<?php // phpcube v1.0.0 Encrypted - Tamper-Proof
// Zero-Disk RAM Execution | Requires phpcube Loader
/* PHPCUBE_PAYLOAD_START */
rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sWAnFFqAw...
8x4f9a0c1b2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c...
/* PHPCUBE_PAYLOAD_END */
✓ Copied!