---
product: Chilkat
product_version: 11.7.0
language: phpext
language_label: PHP Extension
document: language guide
---
> Chilkat 11.7.0 · language=phpext · this file: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/phpext/guide.md`
> Class pages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/phpext/classes/<Class>.md`

# Chilkat for PHP Extension — language guide — v11.7.0

## 1. Which Chilkat binding this is

This is the **Chilkat PHP extension** (native, `chilkat.so` / `chilkat.dll`): classes `CkHttp`, `CkZip`, `CkBinData`, …, created with `new CkHttp()`; properties through `get_Xxx()` / `put_Xxx(...)` methods; string-producing methods also have a lowercase-initial form that returns the string. Not the "PHP ActiveX" binding (COM from PHP on Windows) and not the "Chilkat2 PHP" binding in preparation (`composer require chilkat/chilkat2`, different spelling).

## 2. Install and requirements

```
composer require chilkat/chilkat
```

Or install the extension for your PHP version by hand: [https://www.chilkatsoft.com/installphpextension.asp](https://www.chilkatsoft.com/installphpextension.asp) (Windows, Linux, Alpine, macOS). With Composer, `require 'vendor/autoload.php'` loads the classes; with a manual install, `include("chilkat.php")` or load the extension in `php.ini`.

## 3. Unlocking and object creation

```php
<?php
require 'vendor/autoload.php';   // Composer install

// Required once per process, before any other Chilkat object. Any string unlocks a 30-day trial.
$glob = new CkGlobal();
$success = $glob->UnlockBundle('Anything for 30-day trial');
if ($success != true) {
    print $glob->lastErrorText() . "\n";
    exit;
}

$http = new CkHttp();
```

- Unlocking only sets a flag in memory: no license files, no network call, so the call is repeated each time the program runs. Extra calls are harmless no-ops; the `Global` object can be discarded afterwards.
- If a program forgets to unlock, Chilkat runs in trial mode and stops working when the trial expires — always include the call, and use the purchased unlock code in production.
- `UnlockBundle` unlocks every class; per-class `UnlockComponent` methods exist only in old code.

## 4. Error model

Chilkat methods **do not throw** for Chilkat-level failures. The note under each method on the class page says how it reports failure: a boolean status method returns `false`; the lowercase-initial string form (`$http->quickGetStr($url)`) returns `null` on failure, while the uppercase form fills a `CkString` argument and returns `bool`; object-returning methods return `null`; for an int result check `get_LastMethodSuccess()`. `lastErrorText()` holds the diagnostic in every case.

Literals in PHP Extension: true is `true`, false is `false`, null/none is `null`.

## 5. Strings, bytes and encodings

- Strings are PHP strings (UTF-8 by default); a `charset` argument names the encoding of the *bytes* being produced or read.
- Binary data goes through `CkByteData` / `CkBinData` objects (`Bd` methods); `getBytes()` returns a PHP binary string.
- Methods with `2`/`3` suffixes or `Quick*` prefixes are distinct members, not overloads.

## 6. Object lifetime and threading

Objects are released when PHP's reference count drops to zero; nothing explicit is needed.

A Chilkat object may be used from any thread, but **one object must not be used by two threads at the same time**: create one object per thread or protect it with a lock. Objects are independent — there is no shared global state other than the unlock flag and the few `Global` settings.

## 7. Progress callbacks and async

This binding has **no progress callbacks**. For progress, percent-done or cancellation, use the `*Async` variant of a method (every method with an "Async variant" line on its class page has one). `XAsync` takes the same arguments, returns a `Task` immediately, and the result is read from the task after it finishes: run it, poll `Finished` (or wait), then `GetResultBool` / `GetResultString` / `GetResultBytes` etc.; `PercentDone` and `Cancel` are on the task. No new Async methods are added from 11.7.0 on.

## 8. Common mistakes an AI makes with this binding

1. Using property syntax (`$http->Port = 443`) — in this binding it is `$http->put_Port(443)` and `$http->get_Port()`.
2. Writing Chilkat2-PHP spelling (`new Chilkat\\Http()` or `Http` without `Ck`) against this extension.
3. Omitting `Global.UnlockBundle` (the program runs in trial mode and stops working after 30 days).
4. Inventing members by analogy with other libraries. If a member is not on the class page, it does not exist — look it up rather than guessing.
5. Using deprecated members that older examples still show. The class page lists each one with its replacement; `deprecated.md` lists them all.
6. Ignoring the failure path. Every Chilkat method reports failure (see each method's note); `LastErrorText` says why, and printing it is the first debugging step.
7. Using one Chilkat object from two threads at the same time. Create one object per thread, or protect it with a lock.

## 9. Instructions block for coding agents

Paste into `CLAUDE.md`, `.cursor/rules`, or Copilot instructions:

```
This project uses Chilkat 11.7.0 from PHP (the PHP extension: composer require chilkat/chilkat; classes CkHttp, CkZip, ...).
- Reference: https://www.chilkatsoft.com/ai-docs/v/11.7.0/phpext/ — read guide.md once, then classes/<Class>.md for each class used.
- Call (new CkGlobal())->UnlockBundle(...) once at startup.
- Properties are methods: put_Xxx(v) to set, get_Xxx() to read.
- Chilkat methods never throw on failure: check the false/null result and print $obj->lastErrorText().
- Never use a member that is not on the class page; never use members listed as deprecated.
```

## 10. Classes

[Class index for PHP Extension](https://www.chilkatsoft.com/ai-docs/v/11.7.0/phpext/index.md)
