kokiddp / phptela
CulturaTela PHP API wrapper
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/kokiddp/phptela
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.9
- illuminate/collections: ^10.48
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