kokiddp/phptela

CulturaTela PHP API wrapper

1.0.4 2024-11-14 15:16 UTC

This package is auto-updated.

Last update: 2025-08-14 16:49:27 UTC


README

PHPTela is a simple PHP client library for interacting with the CulturaTela API. It provides methods to retrieve activities and activity lists from the CulturaTela service.

Installation

You can install PHPTela via Composer. Run the following command:

composer require kokiddp/phptela

Requirements

  • PHP 8.1 or higher

Usage

1. Initialize the client

To use the client, you need to instantiate the TelaClient class:

use KokiDDP\PHPTela\TelaClient;

$client = new TelaClient();

2. Get an activity by its ID

To retrieve an activity by its activityID, use the getActivity method:

$activityId = 'your_activity_id';
$response = $client->getActivity($activityId);
$activity = $response->get();
echo $activity->title;

3. Get all activities

To retrieve all activities, use the getAllActivities method:

$response = $client->getAllActivities();
$activities = $response->get();
foreach ($activities as $activity) {
    echo $activity->title;
}

4. Work with the collection

A few handy methods are included:

$response = $client->getAllActivities();
$activities = $response->filterByTitle('something')->get();
$activities = $response->filterByType('Museo')->get();
$activities = $response->search('keyword')->get();
$activities = $response->filterByCreator('someCreatorId')->get();
$activities = $response->filterByCity('Lucca')->get();
$activities = $response->filterByDates(new DateTimeImmutable('now'), new DateTimeImmutable('next month'))->get();
$activities = $response->orderByStartDate()->get();

The methods can be chained:

$response = $client->getAllActivities();
$activities = $response
    ->filterByType('Evento')
    ->filterByCity('Lucca')
    ->filterByDates(new DateTimeImmutable('now'), new DateTimeImmutable('next month'))
    ->orderByStartDate()
    ->get();

A generic filter method that accepts a callable is included:

$response = $client->getAllActivities();
$activities = $response
    ->where(fn(Activity $activity) => $activity->isOpen)
    ->get();

Login

Login to CulturaTela service

$response = $client->login('em@i.l', 'password');
$user = $response->get();

License

This library is licensed under the GPL-3.0-or-later License. See the LICENSE file for details.

Authors

  • Gabriele Coquillard @ ELK-Lab - Email