Skip to main content

PHP SDK

bailaya/api-php is a Composer package for PHP 8.1+.

Installation

composer require bailaya/api-php

Setup

use BailaYa\Client;

$client = new Client([
'studioId' => 'your-studio-id',
// 'baseUrl' => 'https://www.bailaya.com/api', // default
]);

The client also reads BAILAYA_STUDIO_ID from .env (via vlucas/phpdotenv) if no studioId is passed.

Methods

// Studio profile
$profile = $client->getStudioProfile();
echo $profile->name;
echo $profile->description['en']; // localized

// Instructors
$instructors = $client->getInstructors();
foreach ($instructors as $instr) {
echo $instr->name . ' ' . $instr->lastname;
echo $instr->bio['es'] ?? '';
}

// Classes (next 7 days)
$classes = $client->getClasses();
foreach ($classes as $cls) {
echo $cls->name . ' on ' . $cls->date->format('Y-m-d');
echo ' Price: ' . ($cls->price ?? 'Free');
}

// Classes by type
$salsa = $client->getClassesByType('Salsa');

// Events
$events = $client->getEvents();

// Packages
$packages = $client->getPackages();
foreach ($packages as $pkg) {
echo $pkg->name . ' — ' . $pkg->price . ' ' . $pkg->currency;
// Purchase URL: https://www.bailaya.com/packages/{$pkg->id}
}

// Private lesson instructors
$instructors = $client->getPrivateLessonInstructors();
foreach ($instructors as $instr) {
foreach ($instr->pricing as $entry) {
echo $entry->durationMins . ' min — ' . $entry->price . ' ' . $entry->currency;
}
// Booking URL: https://www.bailaya.com/en/book/private-lesson/{$instr->id}
}

DTOs

All methods return typed DTO objects. Nullable fields (price, capacity, room, allowPackages, description) may be null — always check before using.

$cls->price;        // float|int|null
$cls->capacity; // ?int
$cls->room; // ?string
$cls->allowPackages; // ?bool
$cls->description; // ?array<string,string>

Logging

Pass a PSR-3 logger as the second constructor argument:

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('bailaya');
$logger->pushHandler(new StreamHandler('php://stderr'));

$client = new Client(['studioId' => 'studio_abc'], $logger);