protectyourephp / pyp-ext
PYP (ProtectYourePHP) - native PHP extension for the PYP loader
Package info
github.com/ProtectYourePHP/pyp-ext
Language:C
Type:php-ext
Ext name:ext-pyp
pkg:composer/protectyourephp/pyp-ext
Requires
- php: >=8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-13 17:50:34 UTC
README
Native PHP extension for PYP (ProtectYourePHP), the open source PHP encoder and
licensing system. Files built with pyp encode --require-ext only run with this extension.
All other encoded files work without it; when installed, the loader detects it and uses its
native helpers automatically - no code changes needed.
This repository is split from
ProtectYourePHP/ProtectYourePHP(ext/). Please open pull requests there.
What it does (0.3)
| Compile hook | runs files built with pyp encode --require-ext: the decrypted source goes straight to the PHP compiler and never reaches PHP code |
pyp_macs(): array |
MAC addresses of all non-loopback interfaces (aa:bb:cc:dd:ee:ff) - natively, without exec() |
pyp_ext_info(): array |
version, loader_api, features |
PYP_EXT_VERSION, PYP_LOADER_API |
constants |
The loader uses pyp_macs() for MAC address binding of licenses. Without the extension it
falls back to net_get_interfaces(), /sys/class/net or exec('ip link') - which fails on many
shared hosts.
Text form (new in 0.3). Since encoder 1.5 protected PHP files are plain text (a base64 block
after __halt_compiler();). Extension 0.3 reads both this form and the binary form of older
builds and of pyp encode --binary; extension 0.2 only reads the binary form.
Compile hook (since 0.2). Licensing still happens in pyp-loader.php, which hands the
file key to the extension. Protected files are compiled on every request (they are not stored
in OPcache yet). Encrypted data files are read with \Pyp\Loader::read($file).
Supported: PHP 8.1 - 8.5, NTS and ZTS, Linux x86_64, macOS, Windows x64.
Install
1. Find out which build you need
php -v # PHP version, e.g. 8.4.x php -i | grep -E "Thread Safety|Compiler|Architecture|PHP Extension Build" php -i | grep extension_dir # where extensions go
- Thread Safety
disabled=nts,enabled=ts - Windows: Compiler Visual C++ 2019 =
vs16(PHP 8.1-8.3), Visual C++ 2022 =vs17(PHP 8.4+)
2a. Windows
-
Download the zip matching your PHP from the latest release, e.g.
php_pyp-0.3.0-8.4-nts-vs17-x86_64.zip. -
Copy the DLL from the zip into your
extension_dir(usuallyC:\php\ext) and rename it tophp_pyp.dll(in the zip it is calledphp_pyp-0.3.0-8.4-nts-vs17-x86_64.dll; PIE renames it automatically).Expand-Archive php_pyp-0.3.0-8.4-nts-vs17-x86_64.zip -DestinationPath pyp Copy-Item pyp\php_pyp-0.3.0-8.4-nts-vs17-x86_64.dll C:\php\ext\php_pyp.dll
-
Add to
php.ini:extension=pyp -
Restart the web server / PHP-FPM / IIS application pool.
2b. Linux
With PIE (builds for your exact PHP, recommended):
pie install protectyourephp/pyp-ext
Prebuilt (x86_64, glibc, for PHP from the usual distro/ondrej/sury packages):
tar -xzf php_pyp-0.3.0-8.4-nts-linux-x86_64.tar.gz sudo cp php_pyp-0.3.0-8.4-nts-linux-x86_64/pyp.so "$(php-config --extension-dir)/" echo "extension=pyp" | sudo tee /etc/php/8.4/mods-available/pyp.ini sudo phpenmod pyp && sudo systemctl reload php8.4-fpm # Debian/Ubuntu
On other distributions add extension=pyp to php.ini (or a file in php --ini's scan directory).
From source (Linux, macOS):
git clone https://github.com/ProtectYourePHP/pyp-ext.git && cd pyp-ext phpize ./configure --enable-pyp make make test TESTS=tests NO_INTERACTION=1 sudo make install # then add extension=pyp to php.ini
3. Check it works
php -m | grep pyp php -r 'print_r(pyp_ext_info()); print_r(pyp_macs());'
For the web server SAPI, check phpinfo(): there is a section PYP (ProtectYourePHP) support.
Try it without touching php.ini:
php -d extension=/full/path/to/php_pyp.dll -r 'var_dump(extension_loaded("pyp"));'
Using it with encoded applications
Nothing to configure. When the extension is loaded, the PYP loader (pyp/pyp-loader.php)
uses it automatically. Licenses with MAC addresses then work on servers where exec() is disabled.
Roadmap
loader_api 2 adds a zend_compile_file hook that decrypts PYP files in C, so decrypted
source never reaches userland and OPcache can cache protected code. See
docs/native-extension.md.
Troubleshooting
| Message | Cause |
|---|---|
Unable to load dynamic library 'pyp' |
file not in extension_dir, or wrong name (Windows: php_pyp.dll, Linux: pyp.so) |
Module compiled with module API=... PHP compiled with module API=... |
build for another PHP version - take the matching zip/tarball |
...is not a valid Win32 application / %1 is not a valid... |
wrong architecture, or ts build on nts PHP (or vice versa) |
| Works on CLI but not on the website | the web server uses another php.ini - check phpinfo() → Loaded Configuration File |
License
MIT