PHP SDK
Official Misar.Dev SDK for PHP — build, deploy, and manage apps via api.misar.io/dev.
The official Misar.Dev client SDK for PHP.
Installation
composer require misar-ai/misardev-phpRequires PHP >= 8.1 and guzzlehttp/guzzle ^7.0. Classes are autoloaded under the MisarDev\ PSR-4 namespace.
Quick start
<?php
require 'vendor/autoload.php';
use MisarDev\Client;
$client = new Client('mdk_your_api_key');
$projects = $client->projectsList();
print_r($projects);
The constructor accepts optional base URL, retry, and timeout overrides:
$client = new Client(
apiKey: 'mdk_your_api_key',
baseUrl: 'https://api.misar.io/dev',
maxRetries: 3,
timeout: 30.0,
);
Configuration
Base URL https://api.misar.io/dev; auth Authorization: Bearer <key> (set automatically on every request). Retries (default 3) apply to 429, 500, 502, 503, 504 with exponential backoff (base 500 ms). Default timeout 30 s. Every method returns a decoded associative array.
Resources
This PHP port (v1.0.0) implements a subset of the full Misar.Dev API:
public function projectsList(): array
public function projectsCreate(array $params): array
public function apiKeysList(): array
public function usageGet(): array
public function chatComplete(array $params): array
public function templatesList(): array
projects—projectsList,projectsCreateapiKeys—apiKeysListusage—usageGetchat—chatCompletetemplates—templatesList
Error handling
The SDK throws two exception types from the MisarDev\Exceptions namespace:
ApiException— thrown on any non-200 response. Exposes$status(HTTP code) and$errorType(defaults toapi_error).NetworkException— extendsApiExceptionwith status0and error typenetwork_error; thrown when retries are exhausted on a connection failure.
Catch NetworkException before ApiException, since it is a subclass:
use MisarDev\Exceptions\ApiException;
use MisarDev\Exceptions\NetworkException;
try {
$projects = $client->projectsList();
} catch (NetworkException $e) {
fwrite(STDERR, "Network error: {$e->getMessage()}\n");
} catch (ApiException $e) {
fwrite(STDERR, "API error {$e->status} ({$e->errorType}): {$e->getMessage()}\n");
}