uchm4n / api-client
Any API Wrapper client library
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/uchm4n/api-client
Requires
- php: ^7.4|^8.1
- guzzlehttp/guzzle: ^7.4
- pestphp/pest: ^1.21
README
Seamlessly integrate REST APIs into your PHP projects.
This is a lightweight, framework-agnostic package designed to wrap any API with minimal effort. Built on top of Guzzle, it eliminates boilerplate code, allowing you to focus on data rather than HTTP handshake mechanics.
Below is an example demonstrating integration with the JSONPlaceholder API.
Features
- 🚀 Framework Agnostic: Works with Laravel, Symfony, or vanilla PHP.
- âš¡ Guzzle Powered: Leverages the robustness of the Guzzle HTTP client.
- 🔌 Plug & Play: Designed for instant integration and rapid prototyping.
Installation
composer require uchm4n/api-client
Usage
<?php require_once 'vendor/autoload.php'; use uchm4n\APIClient; $api = new APIClient(); // 1. Fetch all resources $posts = $api->getPosts(); // 2. Fetch a specific resource $post = $api->getPostByID(1); // 3. Fetch resources with relationships $postWithComments = $api->getPostWithComments(1); $comments = $api->getCommentsByPost(5); // 4. Create a new resource (POST) $api->savePost([ 'title' => 'New Entry', 'body' => 'Content goes here...', 'userId' => 1, ]); // 5. Update a resource (PUT) $api->updatePost([ 'id' => 1, 'title' => 'Updated Title', 'body' => 'Updated content...', 'userId' => 1, ]); // 6. Partial update (PATCH) $api->patchPost([ 'id' => 1, 'title' => 'Patched Title', ]); // 7. Delete a resource $api->deletePost(5);