json placeholder
v2.0.0
A PHP SDK for the json placeholder API.
You can install the package via composer:
composer require alphaolomi/json-placeholder
$api = new JsonApi();
$users = $api->users()->list();
foreach($users as $user) {
echo $user->name;
}
Shorthand
$users = (new JsonApi())->users()->list();
print_r($users);
// array:10 [
// 0 => array:8 [
// "id" => 1
// "name" => "Leanne Graham"
// "username" => "Bret"
// "email" => "[email protected]"
// "address" => array:5 [▶]
// "phone" => "1-770-736-8031 x56442"
// "website" => "hildegard.org"
// "company" => array:3 [▶]
// ]
// 1 => array:8 [▶]
// ]
You may prefer to retrieve all the results from the paginated requests by using the paginator
method on the SDK.
$api = new JsonApi();
$results = $api->users()->paginate();
foreach($results as $result) {
// Handle result
echo $result->name;
}
Using PestPHP Testing framework, run the following command to execute the tests.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.