PHP code example of suitcasephp / builder

1. Go to this page and download the library: Download suitcasephp/builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

suitcasephp / builder example snippets


use Suitcase\Builder\SDK;

$sdk = SDK::make('https://api.example.com');

$sdk->add('posts', [
    'endpoint' => 'posts',
    'allows' => [
        'get', 'find', 'create', 'update', 'delete'
    ]
]);

$sdk->add('posts');

$sdk->use('posts');

$sdk->use('posts')->get(); // return all posts
$sdk->use('posts')->find(1); // return the post with an identifier of 1
$sdk->use('posts')->create([]); // create a new post
$sdk->use('posts')->update(1, []); // update a post with an identifier of 1
$sdk->use('posts')->delete(1); // delet the post with a identifier of 1

$sdk->use('posts')->append('comments')->find(1);

$sdk->use('users')->withAuthHeaders('your-api-token', 'Bearer')->get();