1. Go to this page and download the library: Download synara/sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
synara / sdk example snippets
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());
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'));
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";
}
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
);
$event = Event::make('uid-123', 'Test', new DateTimeImmutable('2024-01-01T10:00:00Z'));
$jsCalendar = $event->toArray();
$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