PHP code example of globus-studio / php-obfuscator

1. Go to this page and download the library: Download globus-studio/php-obfuscator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

globus-studio / php-obfuscator example snippets




LOBUSstudio\PhpObfuscator\Obfuscator;
use GLOBUSstudio\PhpObfuscator\Options;

$obfuscator = new Obfuscator();

echo $obfuscator->obfuscate(<<<'PHP'

function greet(string $name): string {
    return "Hello, $name";
}
echo greet('Ada');
PHP);

$obfuscator = new Obfuscator(new Options(seed: 42));

$code = $obfuscator->obfuscate(' echo 1 + 1;');
$code = $obfuscator->obfuscateFile(__DIR__ . '/src/in.php');
$obfuscator->obfuscateFileTo(__DIR__ . '/src/in.php', __DIR__ . '/build/out.php');

$map = $obfuscator->getNameMap();
// [
//     'variables'  => ['userName' => 'vAbCdEfG', ...],
//     'functions'  => [...],
//     'classes'    => [...],
//     'methods'    => [...],
//     'properties' => [...],
//     'constants'  => [...],
// ]

use GLOBUSstudio\PhpObfuscator\Options;

$options = new Options(
    encodeStrings: false,
    wrapWithEval: false,
    seed: 12345,
);

$options = Options::fromArray(['wrapWithEval' => false]);
$options = $options->with(['seed' => 7]);

use GLOBUSstudio\PhpObfuscator\Obfuscator;
use GLOBUSstudio\PhpObfuscator\Options;

// Public API stays callable from the outside while the internals are scrambled.
$opts = new Options(
    obfuscateClasses:  false,
    obfuscateMethods:  false,
    obfuscateFunctions: false,
);

echo (new Obfuscator($opts))->obfuscate(file_get_contents('Library.php'));
bash
composer 
bash
vendor/bin/php-obfuscate src/Acme/Service.php build/Service.php
cat src/Acme/Service.php | vendor/bin/php-obfuscate - > build/Service.php
vendor/bin/php-obfuscate --keep-classes --seed=1 src/Service.php