PHPackages                             synara/sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. synara/sdk

ActiveLibrary[API Development](/categories/api)

synara/sdk
==========

PHP SDK for the Synara API

v1.0.0(5mo ago)03MITPHPPHP ^8.1

Since Nov 26Pushed 5mo agoCompare

[ Source](https://github.com/SynaraDotEvents/php-sdk)[ Packagist](https://packagist.org/packages/synara/sdk)[ RSS](/packages/synara-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Synara PHP SDK
==============

[](#synara-php-sdk)

A model-first PHP SDK for the Synara API. Build events with a fluent, immutable API and manage them through resource classes.

Installation
------------

[](#installation)

```
composer require synara/sdk
```

Quick Start
-----------

[](#quick-start)

```
use Synara\Client;
use Synara\Api\Models\Event;
use DateTimeImmutable;
use DateInterval;

$client = new Client(
    apiKey: 'your-api-key-here'
);

$event = Event::make(
    uid: 'unique-event-id',
    title: 'Team Meeting',
    startsAt: new DateTimeImmutable('2024-01-15T10:00:00+00:00')
)->withDuration(new DateInterval('PT1H'));

$createdEvent = $client->events()->create($event);
printf("Event created: %s\n", $createdEvent->getUid());
```

> **Timezone requirement:** the Synara API expects ISO 8601 timestamps with timezone offsets. Make sure your `DateTimeImmutable` values include an offset (e.g. `2024-01-15T10:00:00-08:00`).

Resources &amp; Requests
------------------------

[](#resources--requests)

`Client` exposes typed resources. Each resource turns models into HTTP payloads for you, so you never have to hand-craft JSON.

- `$client->events()->create(Event $event): Event`
- `$client->events()->find(string $uid): Event`
- `$client->events()->update(string $uid, Event $event): Event`

Every response is converted back into immutable model instances, ready for fluent reuse.

Creating Events
---------------

[](#creating-events)

Build an event with `Event::make()` and then chain fluent modifiers. Every method returns a new immutable instance.

```
use Synara\Client;
use Synara\Api\Models\Event;
use DateTimeImmutable;
use DateInterval;

$client = new Client(apiKey: 'your-api-key');

$event = Event::make(
    uid: 'meeting-123',
    title: 'Team Standup',
    startsAt: new DateTimeImmutable('2024-01-15T10:00:00-08:00')
)
    ->withDuration(new DateInterval('PT30M'))
    ->withDescription('Daily team standup meeting')
    ->atLocation('Conference Room A');

$createdEvent = $client->events()->create($event);
printf("Created %s starting at %s\n", $createdEvent->getUid(), $createdEvent->getStartsAt()->format('c'));
```

The SDK automatically serializes this model into a JSCalendar `jsevent` payload when you call `create()` or `update()`. You work with PHP models; the SDK handles converting them to JSON that Synara understands.

Adding Attendees
----------------

[](#adding-attendees)

Attendees are added using the fluent API:

```
use Synara\Api\Models\Attendee;

// Create an attendee
$attendee = Attendee::make(
    email: 'alice@example.com',
    name: 'Alice Smith'
);

// Optional attendee
$optionalAttendee = Attendee::make('bob@example.com', 'Bob Jones')
    ->asOptional();

// Attendee with RSVP status
$acceptedAttendee = Attendee::make('charlie@example.com', 'Charlie Brown')
    ->accepted();

$declinedAttendee = Attendee::make('dave@example.com', 'Dave Wilson')
    ->declined();

// Add attendees to event
$event = Event::make(
    uid: 'meeting-123',
    title: 'Team Meeting',
    startsAt: new DateTimeImmutable('2024-01-15T10:00:00Z')
)
    ->addAttendee($attendee)
    ->addAttendee($optionalAttendee)
    ->addAttendee($acceptedAttendee)
    ->addAttendee($declinedAttendee);

$createdEvent = $client->events()->create($event);
```

Updating Events
---------------

[](#updating-events)

Because models are immutable, every modifier returns a new instance. Persist updates by sending the modified model back to the resource.

```
$event = $client->events()->find('meeting-123');

$updated = $event
    ->withDescription('Updated description')
    ->atLocation('New Location')
    ->addAttendee(Attendee::make('new@example.com', 'New Attendee'));

$saved = $client->events()->update($updated->getUid(), $updated);
printf("Updated %s to %s\n", $saved->getUid(), $saved->getLocation());
```

Finding Events
--------------

[](#finding-events)

```
$event = $client->events()->find('meeting-123');

printf("Title: %s\n", $event->getTitle());
printf("Starts: %s\n", $event->getStartsAt()->format('c'));
printf("Location: %s\n", $event->getLocation() ?? 'n/a');

foreach ($event->getAttendees() as $attendee) {
    printf("Attendee: %s (%s)\n", $attendee->getEmail(), $attendee->getName() ?? 'no name');
}
```

Error Handling
--------------

[](#error-handling)

The SDK throws specific exceptions for different error scenarios:

```
use Synara\Api\Exceptions\AuthenticationException;
use Synara\Api\Exceptions\ValidationException;
use Synara\Api\Exceptions\NetworkException;
use Synara\Api\Exceptions\ApiException;

try {
    $event = $client->events()->create($event);
} catch (AuthenticationException $e) {
    // 401 or 403 - Invalid API key or insufficient permissions
    echo "Authentication failed: {$e->getMessage()}\n";
} catch (ValidationException $e) {
    // 422 - Validation errors
    echo "Validation failed: {$e->getMessage()}\n";
    $errors = $e->getErrors();
    if ($errors) {
        print_r($errors);
    }
} catch (NetworkException $e) {
    // 500+ - Server errors or network issues
    echo "Network error: {$e->getMessage()}\n";
} catch (ApiException $e) {
    // Other API errors
    echo "API error: {$e->getMessage()}\n";
}
```

Custom HTTP Client
------------------

[](#custom-http-client)

You can inject a custom PSR-18 HTTP client:

```
use Psr\Http\Client\ClientInterface;
use GuzzleHttp\Client as GuzzleClient;

$customClient = new GuzzleClient([
    'timeout' => 30,
    // ... other Guzzle options
]);

$client = new Client(
    apiKey: 'your-api-key',
    httpClient: $customClient
    // baseUri defaults to https://synara.events
);
```

Model Properties
----------------

[](#model-properties)

### Event

[](#event)

- `getUid(): string` - Event unique identifier
- `getTitle(): string` - Event title
- `getStartsAt(): DateTimeInterface` - Event start time
- `getDuration(): ?DateInterval` - Event duration (if set)
- `getDescription(): ?string` - Event description (if set)
- `getLocation(): ?string` - Event location (if set)
- `getAttendees(): array` - Array of Attendee objects
- `getStatus(): string` - Event status (default: 'confirmed')

### Attendee

[](#attendee)

- `getEmail(): string` - Attendee email address
- `getName(): ?string` - Attendee name (if set)
- `getKind(): string` - Attendee kind (default: 'individual')
- `getRole(): ?string` - Attendee role (e.g., 'optional')
- `getRsvpStatus(): ?string` - RSVP status, e.g. 'accepted', 'declined', 'needs-action' (or null if not set)

Serialization &amp; Payloads
----------------------------

[](#serialization--payloads)

- `Event::toArray()` returns a PHP associative array that matches the JSCalendar `jsevent` shape. The SDK JSON-encodes this structure whenever it calls the Synara API.
- `Attendee::toArray()` returns the JSCalendar participant structure (email, optional name, role, RSVP status, etc.).

Example JSCalendar output:

```
$event = Event::make('uid-123', 'Test', new DateTimeImmutable('2024-01-01T10:00:00Z'));
$jsCalendar = $event->toArray();
```

```
{
    \"@type\": \"jsevent\",
    \"uid\": \"uid-123\",
    \"title\": \"Test\",
    \"start\": \"2024-01-01T10:00:00+00:00\"
}

```

Testing
-------

[](#testing)

Run the test suite:

```
composer install
vendor/bin/phpunit
```

The test suite includes:

- **EventModelTest** - Tests for Event model immutability, fluent API, and serialization
- **AttendeeModelTest** - Tests for Attendee model methods and serialization
- **EventsResourceTest** - Tests for Events resource with mocked HTTP client

Immutability
------------

[](#immutability)

All models are immutable. Methods like `withDuration()`, `withDescription()`, `addAttendee()`, etc., return new instances:

```
$event1 = Event::make('uid-123', 'Test', new DateTimeImmutable('2024-01-01T10:00:00Z'));
$event2 = $event1->withDescription('Description');

// $event1 is unchanged
assert($event1->getDescription() === null);
assert($event2->getDescription() === 'Description');
assert($event1 !== $event2); // Different instances
```

License
-------

[](#license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance70

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

171d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7898475173f5137cc8abcfa8585c70c7317410ad80a6b9ce0985bc6282c2b261?d=identicon)[synara](/maintainers/synara)

---

Top Contributors

[![SamBenson](https://avatars.githubusercontent.com/u/136246?v=4)](https://github.com/SamBenson "SamBenson (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/synara-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/synara-sdk/health.svg)](https://phpackages.com/packages/synara-sdk)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[vin-sw/shopware-sdk

A PHP SDK for Shopware 6 Platform

122469.3k6](/packages/vin-sw-shopware-sdk)[yoti/yoti-php-sdk

Yoti SDK for quickly integrating your PHP backend with Yoti

27539.9k1](/packages/yoti-yoti-php-sdk)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
