Chilkat2 for PHP — Downloads
Chilkat2 for PHP is the PHP-style Chilkat API: the chilkat2 extension, with classes
in the Chilkat2 namespace (Chilkat2\Http, Chilkat2\JsonObject, …), real
PHP properties ($http->ConnectTimeout = 10), methods that throw Chilkat2\Exception when
they fail, typed signatures that work with declare(strict_types=1) and named arguments, and progress
callbacks you write as closures. HTTP and REST, email, FTP, SFTP, SSH, zip, encryption, signatures, certificates,
XML, JSON, sockets and more, for PHP 8.1 through 8.5 on Windows, Linux, Alpine Linux and macOS.
new Chilkat2\Http(), $http->QuickGetStr($url), exceptions, no file to include) is for
new code. The classic extension (include "chilkat.php", new CkHttp(), status codes) is
unchanged and remains on the Chilkat PHP downloads page; the two are separate extensions
(chilkat and chilkat2) and can be installed side by side.
See the differences.
Jump to: Which download? · Windows · Linux · Alpine Linux · macOS · Getting started · Web servers & Docker · The API in brief · Troubleshooting
Documentation & Samples
- 📦 In every download:
chilkat2.stub.php, which gives PhpStorm, VS Code (Intelephense), PHPStan and Psalm the classes, types and documentation of the extension - 📝 Release Notes on the Chilkat blog
Which download do I need?
A PHP extension is built for one PHP minor version (8.1, 8.2, …), for non-thread-safe (NTS) or thread-safe (ZTS/TS) PHP, and for one OS and CPU architecture. All three must match the PHP that will load it. Ask that PHP:
php -r 'echo PHP_MAJOR_VERSION, ".", PHP_MINOR_VERSION, PHP_ZTS ? " ZTS" : " NTS", " ", php_uname("m"), "\n";' # Linux, macOS
php -r "echo PHP_MAJOR_VERSION, '.', PHP_MINOR_VERSION, PHP_ZTS ? ' TS' : ' NTS', ' ', PHP_INT_SIZE * 8, '-bit', PHP_EOL;" :: Windows
A web server may run a different PHP than the command line: check phpinfo()
(“PHP Version”, “Thread Safety”, “Architecture”) when in doubt.
Windows
- NTS, 64-bit→ chilkat2-php-8.x-nts-x64
- Thread-safe, 64-bit→ chilkat2-php-8.x-x64
- 32-bit→ …-win32
NTS: IIS/FastCGI and most command-line installs. Thread-safe: Apache with mod_php.
Linux (glibc)
- NTS→ chilkat2-php-8.x-<arch>-linux
- ZTS→ chilkat2-php-zts-8.x-<arch>-linux
x86_64, x86, aarch64 (arm64), armv7l. Distribution packages, PHP-FPM and the official
php Docker images are NTS.
Alpine Linux (musl)
- NTS→ chilkat2-php-8.x-<arch>-alpine
x86_64, aarch64. For Alpine packages and php:*-alpine Docker images. The glibc
builds do not load on Alpine.
macOS
- NTS→ chilkat2-php-8.x-<arch>-macosx
- ZTS (8.2+)→ chilkat2-php-zts-8.x-<arch>-macosx
arm64 (Apple silicon), x86_64 (Intel). Homebrew's PHP is NTS.
Windows
Each .zip contains a code-signed php_chilkat2.dll, linked with the C runtime statically
(no Visual C++ redistributable needed). Getting started →
Non-thread-safe (NTS)
Thread-safe (TS)
Linux (x86_64, x86, arm64, armv7l)
For glibc-based distributions (Debian/Ubuntu, RHEL/Fedora, SUSE, Arch, Raspberry Pi OS, …). Each
.tar.gz contains chilkat2.so. Alpine Linux uses musl and needs the Alpine downloads below.
The arm64 and armv7l builds start at PHP 8.2. Getting started →
Non-thread-safe (NTS) — the usual build
Thread-safe (ZTS)
Alpine Linux (x86_64, arm64)
Built for musl, non-thread-safe. Each .tar.gz contains chilkat2.so.
Getting started →
macOS (arm64, x86_64)
Each .tar.gz contains a code-signed chilkat2.so. Apple silicon requires macOS 11 or
later; Intel requires macOS 10.14 or later. Getting started →
Non-thread-safe (NTS) — the usual build (Homebrew)
Thread-safe (ZTS)
Getting started
The steps are the same on every operating system; only the archive and the file name differ
(php_chilkat2.dll on Windows, chilkat2.so elsewhere).
-
Download and extract
tar xzf chilkat2-php-8.4-x86_64-linux.tar.gz # Linux / Alpine / macOS (your file name) # Windows: right-click the .zip → Extract All, or: tar -xf chilkat2-php-8.4-nts-x64.zip # Windows 10 and later include tar
macOS only: if the browser added a quarantine attribute, clear it so Gatekeeper does not block the extension:
xattr -dr com.apple.quarantine chilkat2-php-8.4-arm64-macosx
-
What's in the download
chilkat2-php-<version>-<platform>/ ├─ chilkat2.so the extension (php_chilkat2.dll on Windows) ├─ chilkat2.stub.php for your IDE and static analysis — never include it ├─ README.txt ├─ test.php a small check that everything loads └─ license.pdf, THIRD-PARTY-NOTICES.txt, … and a software bill of materials (chilkat.cdx.json)
-
Try it without installing
From the extracted folder:
php -d extension=./chilkat2.so test.php # Linux, Alpine, macOS php -d extension=.\php_chilkat2.dll test.php :: Windows
test.phpprints the Chilkat version, encrypts and decrypts a string, and round-trips some UTF-8 text. If the extension cannot be loaded, it prints the PHP version, thread safety andphp.iniit found; see Troubleshooting. -
Install
Copy the extension into PHP's extension directory:
php -r 'echo ini_get("extension_dir"), "\n";' # where it goes sudo cp chilkat2.so "$(php -r 'echo ini_get("extension_dir");')" :: Windows: copy php_chilkat2.dll into the "ext" folder of your PHPThen enable it: add a line to
php.ini, or (Linux, macOS) to a file of its own in theconf.ddirectory thatphp --inilists, for example20-chilkat2.ini:extension=chilkat2
Check with
php -m(the list includeschilkat2) andphp test.php.phpinfo()shows a chilkat2 section with the Chilkat version. -
Unlock
Chilkat is fully functional for a 30-day trial. Call
UnlockBundleonce when your program starts; any string starts the trial, and your purchased unlock code is used the same way:(new Chilkat2\GlobalSettings())->UnlockBundle('Anything for 30-day trial');
A first program
<?php
declare(strict_types=1);
use Chilkat2\GlobalSettings;
use Chilkat2\Http;
(new GlobalSettings())->UnlockBundle('Anything for 30-day trial');
try {
$http = new Http(['ConnectTimeout' => 10]); // properties may be set in the constructor
$http->onPercentDone(function (int $pct): bool {
echo "$pct%\n";
return false; // true aborts the download
});
$html = $http->QuickGetStr('https://www.chilkatsoft.com/');
echo "HTTP {$http->LastStatus}, ", strlen($html), " bytes\n";
} catch (\Chilkat2\Exception $e) {
echo "{$e->getClass()}::{$e->getMethod()} failed\n";
echo $e->getMessage(), "\n"; // the full LastErrorText of the failed call
}
There is nothing to include: the classes exist as soon as the extension is loaded. For your IDE,
put chilkat2.stub.php where it indexes files (PhpStorm: anywhere in the project or as an external
library; VS Code + Intelephense: in the workspace or in intelephense.environment.includePaths).
Web servers & Docker
PHP-FPM, Apache (mod_php) and IIS (FastCGI) each read their own php.ini, which may differ from the
command line's: enable extension=chilkat2 in the one phpinfo() shows under “Loaded
Configuration File” (or in its conf.d directory), then restart the service
(systemctl restart php8.4-fpm, apachectl graceful, recycle the IIS application pool).
Official php Docker images
Copy the build matching the image's PHP version (Debian-based images: -linux;
php:*-alpine: -alpine) and enable it with the image's helper:
FROM php:8.4-fpm
COPY chilkat2-php-8.4-x86_64-linux/chilkat2.so /tmp/
RUN mv /tmp/chilkat2.so "$(php -r 'echo ini_get("extension_dir");')/" \
&& docker-php-ext-enable chilkat2
The php:*-zts images need the ZTS builds.
The API in brief
Same classes, same members, same behavior as every other Chilkat product.
| Chilkat2 PHP | Classic Chilkat PHP | |
|---|---|---|
| Loading | extension=chilkat2; nothing to include | extension=chilkat plus include "chilkat.php" |
| Classes | new Chilkat2\Http() | new CkHttp() |
| Properties | $http->ConnectTimeout = 30; | $http->put_ConnectTimeout(30); |
| Methods | $http->QuickGetStr($url) | $http->quickGetStr($url) |
| Failure | throws Chilkat2\Exception (getMessage() is the LastErrorText); or, with ['RaiseError' => false], returns false / null | returns false / null; read lastErrorText() |
| “Not found” | lookup methods such as $xml->FindChild($path) return null, no exception | returns null |
| Yes/no methods | $json->HasMember($path) returns bool, never throws | returns bool |
| Strings and bytes | PHP strings (UTF-8 text, or binary data as is) | also CkString, CkByteData; put_Utf8(true) |
| Types | typed parameters and properties: TypeError on a wrong type, named arguments, strict_types | untyped |
| Progress events | onPercentDone(fn), onAbortCheck(fn), onProgressInfo(fn) with closures | — |
Async (*Async, Task) | not included | included |
| Unlocking | (new Chilkat2\GlobalSettings())->UnlockBundle($code) | (new CkGlobal())->UnlockBundle($code) |
Events run during the method call; returning true from an onAbortCheck or
onPercentDone closure aborts the method (it then fails in the usual way). AbortCheck fires
every HeartbeatMs milliseconds, which is how a script limits a long call: PHP's
set_time_limit() does not interrupt a Chilkat method.
Troubleshooting
PHP Startup: Unable to load dynamic library 'chilkat2'- The file is not in
extension_dir(or the path afterextension=is wrong). On Windows, the message ending in “is not a valid Win32 application” means a 32-bit/64-bit mismatch; on Linux, “wrong ELF class” is the same, and “Error loading shared library” or a missingld-linuxmeans a glibc build on Alpine (or the reverse). Module compiled with module API=2023…/PHP compiled with module API=2024…- The download is for a different PHP minor version: use the one for
PHP_MAJOR_VERSION.PHP_MINOR_VERSION(above). Module compiled with build ID=API…,NTS/PHP compiled with build ID=API…,TS- Thread-safety mismatch: a ZTS/TS PHP needs the ZTS/TS download, an NTS PHP the NTS one.
Class "Chilkat2\Http" not found- The extension is not loaded in the PHP that runs the script — often a web server reading a different
php.inithan the command line (above).extension_loaded('chilkat2')tells. - macOS: the extension “cannot be opened” or fails a code-signature check
- Clear the download's quarantine attribute:
xattr -dr com.apple.quarantine <extracted folder>. Error: Undefined property: Chilkat2\Http::$Conecttimeout- Property names are case-sensitive and checked: a misspelled name is an error rather than a silent new property.
Class "Chilkat2\CodeSign" not foundon Linux or macOSCodeSignandScMinidriveruse Windows APIs and exist only in the Windows builds.