Installing the Chilkat PHP Extension on macOS

Step-by-step instructions for installing the Chilkat extension on macOS (Apple Silicon and Intel), plus the checks that prevent the common load and Gatekeeper errors.

The download must match your PHP build A PHP extension only loads into a PHP that matches it:
  • PHP version — e.g. the 8.5 extension for PHP 8.5.
  • Architecturearm64 for Apple Silicon, x86_64 for Intel.
  • Thread safety (ZTS): the ZTS download for a thread-safe PHP, or the regular (non-ZTS) download otherwise. (Homebrew PHP is typically non-ZTS.)
Step 3 shows how to read these from your PHP.
  1. Download

    Get the build for your Mac from the Chilkat macOS PHP Downloads.

  2. What's in the download

    Extract the .tar.gz. It contains:

    chilkat-php-<version>-<arch>-macosx/
    ├─ chilkat.so              the Chilkat PHP extension
    ├─ chilkat.php             PHP class definitions (your script includes this)
    ├─ phpinfo.php             prints your PHP configuration
    ├─ showExtDir.php          prints the extension directory
    ├─ test.php                verifies the install
    ├─ license.pdf
    ├─ pcre2-license.pdf
    ├─ quickjs-license.pdf
    └─ THIRD-PARTY-NOTICES.txt
    Two files, two roles: chilkat.so is the native extension that PHP loads (Steps 5–6). chilkat.php defines the Chilkat classes (CkGlobal, CkHttp, …) and is included by your own scripts — keep it where your script can find it (your project directory or a path on include_path).

    Extract with:

    tar xzf chilkat-php-<version>-<arch>-macosx.tar.gz
  3. Check your PHP version, architecture, and thread safety

    uname -m            # arm64 = Apple Silicon, x86_64 = Intel
    php -v
    php -i | grep -E "Thread Safety|PHP Version"
    php --ini           # shows the Loaded Configuration File (php.ini)

    If Thread Safety is enabled, use the ZTS download; otherwise use the regular download.

  4. Use a non-system PHP (macOS Catalina and later)

    The PHP that ships with macOS lives in a read-only location, so you can't add extensions to it. Install PHP with Homebrew instead:

    brew install php
    brew link php

    Homebrew's extension directory is writable — under /opt/homebrew/… on Apple Silicon or /usr/local/… on Intel. (To pin a version, use e.g. brew install php@8.5.)

  5. Copy chilkat.so to the extension directory

    Find the extension directory:

    php showExtDir.php          # prints ini_get("extension_dir")

    Copy the extension there (create the directory first if it doesn't exist):

    sudo cp chilkat.so "$(php -r 'echo ini_get(\"extension_dir\");')"
    Clear the Gatekeeper quarantine A downloaded .so carries a quarantine attribute that macOS may block with “chilkat.so” cannot be opened because the developer cannot be verified. Remove it before (or after) copying:
    xattr -dr com.apple.quarantine chilkat-php-<version>-<arch>-macosx
  6. Enable the extension in php.ini

    Open the php.ini reported by php --ini, find the Dynamic Extensions section, and add:

    extension=chilkat.so

    If there is no php.ini yet, copy the default first: sudo cp /etc/php.ini.default /etc/php.ini (system PHP), or use the one Homebrew created. If PHP runs under a web server or PHP-FPM, restart it afterward.

  7. Verify with test.php

    Run the included test.php, which unlocks Chilkat in trial mode and performs an AES encrypt/decrypt:

    php test.php

    Successful output looks like:

    Unlocked in trial mode.
    4846f83aa211e239aa62a21f527f089ee9ddbead30ee15d4e79b607a621b97bedb9b6f00a9b21f1b43a50b4c1be0edf2
    The quick brown fox jumps over the lazy dog.
  8. Use Chilkat in your scripts

    Include chilkat.php and unlock once at startup (any string starts the 30-day trial; use your license code after purchase):

    <?php
    include("chilkat.php");
    
    $glob = new CkGlobal();
    $glob->UnlockBundle("Anything for 30-day trial");
    
    // ... use any Chilkat class, e.g. new CkHttp(), new CkJsonObject(), ...
    ?>

    See also: Installing the chilkat.php file for all apps.


Common errors

“Unable to load dynamic library 'chilkat.so'”

Usually a mismatch between the extension and your PHP. Re-check Step 3 and confirm the PHP version, architecture (arm64 vs x86_64), and thread safety (ZTS) all match the download.

“chilkat.so cannot be opened because the developer cannot be verified”

macOS Gatekeeper has quarantined the file. Clear it with xattr -dr com.apple.quarantine <extracted-folder> (see Step 5).

“Class 'CkGlobal' not found”

Your script didn't include the class definitions. Add include("chilkat.php"); and make sure chilkat.php is reachable from your script (same directory or on the include_path).

Can't add extensions to the system PHP

The macOS system PHP has a read-only extension directory. Install PHP via Homebrew (Step 4) and use that one for building, installing, and running.