Registry / devops / uglify-php

uglify-php

JSON →
library1.0.7jsnpmunverified

UglifyPHP is a JavaScript minifier and simple obfuscator for PHP files. It uses a unique ID based on current time to replace variable names, allowing multiple minified files to coexist without variable overwriting. It correctly handles class methods and $this references, but does not modify function names or inject junk code for performance reasons. The package is NOT a security solution and should not be used for licensing or code protection. Current stable version is 1.0.7. It is a lightweight tool for basic PHP code minification and obfuscation, with options to exclude specific variables, remove whitespace, and remove comments. It runs in Node.js and outputs either a minified file or source code as a promise.

npm install uglify-php
INSTALL
IMPORT
SIG · UGLIFY-PHP
U
uglify-php
devopsjavascriptv1.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

UglifyPHP
const UglifyPHP = require('uglify-php');
import UglifyPHP from 'uglify-php';
CommonJS only; no ESM support.
UglifyPHP.minify
UglifyPHP.minify(pathOrCode, options).then(source => ...);
UglifyPHP.minify(pathOrCode, options, callback);
Returns a promise, not a callback.
UglifyPHP.minify (error handling)
UglifyPHP.minify(...).catch(err => console.error(err));
try { UglifyPHP.minify(...) } catch(err) {}
Errors are rejected promises, not thrown synchronously.

Shows CommonJS require usage, option configuration, and promise-based minification with error handling.

const UglifyPHP = require('uglify-php'); const options = { excludes: [ '$GLOBALS', '$_SERVER', '$_GET', '$_POST', '$_FILES', '$_REQUEST', '$_SESSION', '$_ENV', '$_COOKIE', '$php_errormsg', '$HTTP_RAW_POST_DATA', '$http_response_header', '$argc', '$argv', '$this' ], minify: { replace_variables: true, remove_whitespace: true, remove_comments: true, minify_html: false }, output: '' }; UglifyPHP.minify('<?php echo "Hello"; ?>', options) .then(source => console.log(source)) .catch(err => console.error(err));
Debug
Known issues
gotchaUglifyPHP does NOT protect code or prevent reverse-engineering; it only minifies and obfuscates variable names.
fix
Do not rely on this for licensing or security; use a dedicated code protection tool if needed.
affects: >=1.0.0
gotchaThe '.minify' method returns a Promise, not a synchronous result.
fix
Always use .then() or async/await to handle the result.
affects: >=1.0.0
gotchaVariable replacement uses a unique ID based on current time; two minifications at the same moment may produce identical IDs.
fix
If collision is a concern, add a small delay or custom prefix.
affects: >=1.0.0
deprecatedThe package is not actively maintained; last update was 4 years ago.
fix
Consider alternatives like 'php-minify' or 'PHP Minify' if you need active support.
affects: 1.0.7
Errors
Common errors & fixes
TypeError: UglifyPHP.minify is not a function
Incorrect import (ESM import instead of require).
fix
Use const UglifyPHP = require('uglify-php');
UnhandledPromiseRejectionWarning: Error: File not found
The first argument is a file path that does not exist.
fix
Ensure the path is correct, or pass the source code as a string instead.
ReferenceError: regeneratorRuntime is not defined
Using async/await without proper polyfill in older Node.js versions.
fix
Use .then()/catch() or upgrade Node.js to version 7.6+.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
28
OpenAI (training)
1
Resources
uglify-php — npm install uglify-php · libregistry