Search by

PYP (ProtectYourePHP) - native PHP extension for the PYP loader

Package info

github.com/ProtectYourePHP/pyp-ext

Issues

Language:Shell

Type:php-ext

Ext name:ext-pyp

pkg:composer/protectyourephp/pyp-ext

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

0.3.1 2026-11-29 22:22 UTC

This package is auto-updated.

Last update: 2026-11-29 22:27:27 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/pyp-encoder (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

Quick install on Linux servers (Plesk, cPanel, DirectAdmin, aaPanel, plain servers)

One command installs or updates the extension for every PHP version on the server (8.1+):

curl -fsSL https://raw.githubusercontent.com/ProtectYourePHP/pyp-ext/main/install.sh | sudo bash

install.sh finds the PHP installations of Plesk (/opt/plesk/php/*), cPanel EasyApache (/opt/cpanel/ea-php*), CloudLinux alt-php, DirectAdmin, aaPanel, Debian/Ubuntu (/usr/bin/phpX.Y, also HestiaCP, ISPConfig, KeyHelp), Remi on RHEL/Alma/Rocky and the php in the PATH. For each it compiles the extension (installing the compiler and the PHP development package after asking), falls back to the prebuilt Linux build if it cannot compile, enables it for the CLI and PHP-FPM, restarts the matching PHP-FPM services and checks that PHP loads it. Run it again to update; it skips versions that are already current.

sudo bash install.sh --list          # what is installed where
sudo bash install.sh --yes           # non-interactive (installs build packages without asking)
sudo bash install.sh --php=/opt/plesk/php/8.4/bin/php   # only one PHP
sudo bash install.sh --version=0.3.1 --force            # a specific version
sudo bash install.sh --uninstall
sudo bash install.sh --help          # all options

The steps below do the same by hand.

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

  1. Download the zip matching your PHP from the latest release, e.g. php_pyp-0.3.1-8.4-nts-vs17-x86_64.zip.

  2. Copy the DLL from the zip into your extension_dir (usually C:\php\ext) and rename it to php_pyp.dll (in the zip it is called php_pyp-0.3.1-8.4-nts-vs17-x86_64.dll; PIE renames it automatically).

    Expand-Archive php_pyp-0.3.1-8.4-nts-vs17-x86_64.zip -DestinationPath pyp
    Copy-Item pyp\php_pyp-0.3.1-8.4-nts-vs17-x86_64.dll C:\php\ext\php_pyp.dll
  3. Add to php.ini:

    extension=pyp
  4. 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.1-8.4-nts-linux-x86_64.tar.gz
sudo cp php_pyp-0.3.1-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