npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

php-obfuscate

v0.0.4

Published

PHP obfuscator built with Bun. Parses PHP 7.4+ source into an AST, renames identifiers, and emits compact output. No base64, no eval wrappers, no gzip tricks.

Readme

php-obfuscate

PHP obfuscator built with Bun. Parses PHP 7.4+ source into an AST, renames identifiers, and emits compact output. No base64, no eval wrappers, no gzip tricks.

Requirements

  • Bun >= 1.0
  • PHP CLI optional (for --validate-php-lint)

Install

bun install

Usage

bun run src/cli.ts <input.php> [options]

Options

| Flag | Description | | ----------------------------- | ----------------------------------------- | | --out <path> | Write output to file | | --stdout | Write output to stdout | | --config <path> | Load JSON config file | | --seed <value> | Deterministic rename seed | | --check | Dry-run: exit 1 if output differs | | --fail-on-warning | Exit 1 when warnings are emitted | | --validate-php-lint | Run php -l on output | | --rename-variables | Rename local variables (default: on) | | --rename-parameters | Rename function parameters (default: on) | | --rename-functions | Rename file-local functions (default: on) | | --rename-private-methods | Rename private methods (default: on) | | --rename-private-properties | Rename private properties (default: on) | | --transform-strings | Enable string obfuscation (default: off) | | --string-mode <mode> | split, escape, or mixed | | --verbose | Print active config to stderr |

Examples

# Obfuscate and write to file
bun run src/cli.ts src/app.php --out dist/app.php

# Preview on stdout with string obfuscation
bun run src/cli.ts src/app.php --stdout --transform-strings --string-mode escape

# Use a config file
bun run src/cli.ts src/app.php --out dist/app.php --config obfuscator.json

# Check only (CI use)
bun run src/cli.ts src/app.php --check

Config file

{
    "seed": "my-project",
    "rename": {
        "variables": true,
        "parameters": true,
        "functions": true,
        "privateMethods": true,
        "privateProperties": true
    },
    "strings": {
        "enabled": false,
        "mode": "split",
        "minLength": 6,
        "skipPatterns": ["^https?://", "^[A-Z0-9_]+$"]
    },
    "keep": {
        "variables": ["$pdo", "$wpdb"],
        "functions": ["register_routes"],
        "methods": [],
        "properties": []
    },
    "validatePhpLint": true,
    "failOnWarning": false
}

Annotations

Control obfuscation inline with comments. Both line comments (//) and block comments (/* */, /** */) are supported.

// @obfuscate-ignore-file
// Skips the entire file.

// @obfuscate-ignore-next
function sensitiveFunction($value) { ... }

// @obfuscate-keep function myPublicHook
function myPublicHook($v) { ... }

// @obfuscate-keep variable $pdo
$pdo = new PDO(...);

// @obfuscate-keep property connection
private string $connection;

// @obfuscate-keep method handleRequest
private function handleRequest() { ... }

What gets renamed

| Symbol | Renamed | Notes | | ---------------------------------- | ------- | ------------------------------- | | Local variables | Yes | Per function scope | | Function parameters | Yes | Per function scope | | Closure use vars | Yes | Per closure scope | | File-local functions | Yes | And all call sites in same file | | Private methods | Yes | Within class | | Private properties | Yes | Within class | | Public/protected methods | No | | | Class names | No | | | Constants | No | | | Namespaces | No | | | $this, superglobals | No | Always preserved | | Magic methods (__construct etc.) | No | Always preserved |

Safety

The obfuscator skips renaming and emits a warning when it detects:

  • Variable variables ($$name)
  • compact(), extract(), parse_str(), get_defined_vars()
  • call_user_func() / call_user_func_array()
  • global declarations
  • Dynamic property/method access

Use --fail-on-warning to treat any skip as a hard error.

String modes

| Mode | Effect | | -------- | ----------------------------------------- | | off | No string transformation (default) | | split | "secret""sec"."ret" | | escape | "secret""\x73\x65\x63\x72\x65\x74" | | mixed | Left half hex-escaped, right half split |

Only plain string literals are transformed. Strings shorter than minLength or matching skipPatterns are left alone.

Run tests

bun test