# Zactonz PHP SDK: Installation

> PHP client for the Zactonz APIs: QR codes and barcodes, screenshots and PDFs, social card images, image conversion, link previews, page to Markdown, SSL, DNS, WHOIS, email checks and translation.

Page: https://developers.zactonz.com/tools/zactonz-php/installation/

Complete documentation for this product: https://developers.zactonz.com/tools/zactonz-php.md

## Install with Composer

```bash
composer require zactonz/zactonz-php
```

The package is [zactonz/zactonz-php on Packagist](https://packagist.org/packages/zactonz/zactonz-php). Composer installs the current release under `vendor/zactonz/zactonz-php` and registers the `Zactonz` namespace with your autoloader. Nothing else is required; the library depends only on PHP 8.1 or newer with the `curl` and `json` extensions.

## Create API keys

Each Zactonz key works for one product, and the product is part of the key: `zk_qr_…` is a QR key, `zk_screen_…` a screenshot key. Create a key for each product you intend to call in the [API console](https://developers.zactonz.com/console/). There is a free plan.

Pass every key you have to the client. It picks the right one for each call and throws before any request is made if the key for a product is missing.

```php
$zactonz = new Client(['zk_qr_…', 'zk_screen_…', 'zk_domain_…']);
```

To keep keys out of your code, put them in the `ZACTONZ_API_KEYS` environment variable, separated by commas, and call `Client::fromEnvironment()`.

A value that is not a Zactonz key is rejected with `InvalidKeyException` rather than guessed at. Key values are hidden from `var_dump()` and stack traces. Keep them on the server; never ship them to a browser.

## Check a key

```php
if ($zactonz->hasKeyFor('screen')) {
    $left = $zactonz->keyStatus('screen')->get('quota.day.remaining');
}
```

`keyStatus()` calls the API's key check endpoint and returns the plan and the quota remaining today and this month.
