Hapio Logo

Hapio Releases SDK for PHP – Simplifying integration with the Booking and Scheduling API

8 November 2023 - New features

During the last few weeks we have worked on an SDK for PHP, to make it easier for PHP developers to get started with Hapio. We are now happy to announce its release to the public.

The Hapio SDK for PHP is designed to streamline the integration of Hapio’s robust booking and scheduling capabilities into PHP applications, providing developers with a powerful tool to enhance the functionality of their projects.

System Requirements

Before getting started with the Hapio SDK for PHP, developers should ensure that their environment meets the following requirements:

PHP 8.2 or later.

Getting Started

Integrating the Hapio SDK into a PHP project is a straightforward process. Developers can utilize Composer, a popular PHP dependency manager, to include the SDK in their project. Here’s how to get started:

Open your project’s terminal or command prompt.
Run the following Composer command:

Once the SDK is successfully installed, developers can begin using it in their projects.

Working with the SDK

Utilizing the Hapio SDK for PHP is as simple as instantiating an API client and getting to work. Below is an example of how to get started with the SDK:

Documentation and Models

The Hapio SDK for PHP offers comprehensive documentation and includes various models to interact with the Hapio API efficiently. Some of the available models include:

  • Project
  • Location
  • Resource
  • Service
  • ScheduleBlock
  • RecurringSchedule
  • RecurringScheduleBlock
  • Booking
  • BookableSlot
  • TimeSpan
  • ResourceServiceAssociation

These models simplify the interaction with Hapio entities, making it easier to create, update, and retrieve data. Developers can set properties and interact with the models using either snake_case or camelCase naming conventions.


To facilitate communication with the API, the Hapio SDK for PHP provides repository classes for each type of entity available in Hapio. These repositories serve as gateways to send and retrieve data and are accessible through methods on the ApiClient class.

Some of the available repositories include:

  • ProjectRepository
  • LocationRepository
  • ResourceRepository
  • ServiceRepository
  • ScheduleBlockRepository
  • RecurringScheduleRepository
  • RecurringScheduleBlockRepository
  • BookingRepository

Each repository offers a set of methods that correspond to the available API endpoints for the respective entity type.

Paginated Responses

For API endpoints that return paginated lists of data, the Hapio SDK provides a PaginatedResponse class with various methods to simplify handling these responses. Developers can easily navigate paginated data, retrieve items, and determine if there are more pages available.

Exception Handling

The Hapio SDK for PHP includes robust exception handling, ensuring that developers can manage errors effectively. When the API responds with 4XX or 5XX status codes, appropriate exceptions are thrown. Validation errors with a status code of 422 will trigger a ValidationException, while other 4XX and 5XX status codes result in an ErrorException. These exceptions provide access to error messages, status codes, and validation errors when applicable.

With the release of the Hapio SDK for PHP, developers can now seamlessly integrate Hapio’s booking and scheduling capabilities into their PHP projects, enhancing the efficiency and functionality of their applications.

The SDK is available on Packagist.org, ready to be installed via Composer. You can also check out the source code at GitHub.