PHP licensing is a different problem from the rest of this list, because PHP source ships as source. If you host the application yourself you do not need a dongle. If you install it on a customer’s own server — which is exactly where PHP business software tends to live — then the customer has your code, and an encoder such as ionCube or SourceGuardian gives you a licence file, which is a file, which copies.
composer require keynub/licdongleCode language: Bash (bash)
A dongle in the server changes that: the licence is a physical object in one machine, and it cannot be duplicated to the test system, the second site or the competitor’s rack.
use KeyNub\LicDongle\Context;
$ctx = new Context();
$dongle = $ctx->open(); // first dongle found
$dongle->verifyGenuine(); // throws unless genuine
$session = $dongle->openSession();
$license = $session->readRecord('license');Code language: PHP (php)
Practical Notes
The binding uses FFI, so it needs the ffi extension enabled and ffi.enable set appropriately for CLI or FPM. Check the dongle when the application boots or on a schedule rather than on every request — USB round trips are fast but not free, and a per-request check buys nothing an hourly one does not.
And the rule that matters in every language: do not branch on a boolean. Encrypt data your program needs with appEncrypt at build time and decrypt it through the dongle at run time, so removing the check leaves the program with nothing to compute rather than a working unlicensed copy.
Shipping the Native Library with a PHP Application
The keynub/licdongle Composer package uses PHP’s bundled FFI extension, so there is no PECL module to build and no extension to enable beyond ffi.enable=true in php.ini. Composer installs the repository with its natives/ folder, so the library for the platform is there after composer require.
The dongle is attached to the machine running PHP, which makes this a fit for kiosk, point-of-sale, laboratory and on-premises server software rather than for shared hosting. On Linux, install the udev rule from NATIVES.md once, so that ordinary users may open the device.
Questions PHP Developers Ask
Which PHP Versions Does the Binding Support?
PHP 8.1 and later with the FFI extension enabled, on Windows, Linux and macOS.
Can a PHP Application on a Customer’s Server Be Protected with a Dongle?
Yes, when the server is on the customer’s premises with the dongle attached: an intranet application, a device web interface, a local service. The check runs in the PHP process that handles the request.
Does a PHP Application Need Administrator Rights to Talk to the Dongle?
No, and no driver either: the dongle is a USB HID device that the operating systems handle with their built-in class drivers. On Linux, install the shipped udev rule once so that ordinary users may open it; without the rule the SDK reports access denied and names the cause in its error detail.
Does a PHP License Check Need an Internet Connection?
No. Verification is a local exchange between your program and the dongle over USB: the SDK checks the dongle’s certificate chain to KeyNub’s root and runs a live challenge-response. There is no activation server and no account, so the check works on air-gapped machines.
Who Can Read the License Records on a Dongle?
Anyone holding the dongle: a program opens a session and reads records, and can decrypt data sealed for that dongle. Writing records, erasing them and incrementing counters need your write key. What the dongle guarantees is that none of it is available without the dongle present.
Can a License Written from PHP Be Read by a Program in Another Language?
Yes. Every binding drives the same core library and the same dongle, and records and sealed data are language-neutral bytes. Your issuing tool can be written in one language and your product in another.
Code
Runnable sample: php/verify_and_read.php. Binding source: bindings/php. Both are Apache-2.0, in the public SDK repository; the prebuilt native libraries are in the repository’s natives/ folder, one per platform.
All supported languages · All industries · Buy a KeyNub · Ask us something