PHP code example of cierrateam / connect-laravel-sdk

1. Go to this page and download the library: Download cierrateam/connect-laravel-sdk 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/ */

    

cierrateam / connect-laravel-sdk example snippets


    'providers' => [
        // ...
        \Cierra\Connect\ConnectServiceProvider::class,
    ],
    
sh
    php artisan vendor:publish --tag=cierra-connect-config
    


namespace App\Http\Controllers;

use Cierra\Connect\ConnectManager;
use Illuminate\Http\Request;

class TestCierraConnectController extends Controller
{
    public function test(Request $request, ConnectManager $connectManager)
    {
        $CONNECTION = 'my_api_connection_key';
        $apiClient = $connectManager->getInstance($CONNECTION);

        // Get a list of entities
        $items = $apiClient->entity('cars')->list();
        dump($items); // Laravel collection returned
        dump($items->first());
        
        // Pagination
        $items = $apiClient->entity('cars')->list(4, 100);
        dump($items);

        // Get specific item by ID
        $item = $apiClient->entity('cars')->get(314591);
        dump($item);
        
        // Get additional API response data
        $item = $apiClient->entity('cars')->asRawResponse()->get(314588);
        dump($item);
    }