PHP code example of sarfrazrizwan / laravel-webling

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

    

sarfrazrizwan / laravel-webling example snippets


use RizwanSarfraz\Webling\Facades\Webling;

// Or via container resolution:
// $webling = app(RizwanSarfraz\Webling\Webling::class);

// Perform raw HTTP requests
$members = Webling::get('member');
$response = Webling::post('member', ['FirstName' => 'Jane']);
$response = Webling::put('member/123', ['LastName' => 'Doe']);
$response = Webling::delete('member/123');

// Access the underlying Webling\API\Client directly
$rawClient = Webling::raw();

// List all objects (accepts filter, order, format, page/per_page)
$objects = Webling::member()->list([
    'filter' => '`Vorname` = "Hans"',
    'format' => 'full'
]);

// Get a single resource
$member = Webling::member()->get(123);

// Multiget (fetches several IDs in one request comma-joined)
$multipleMembers = Webling::member()->get([536, 525, 506]);

// Create a new resource (returns new object ID)
$newId = Webling::member()->create([
    'FirstName' => 'Hans',
    'LastName' => 'Müller'
]);

// Update a resource
Webling::member()->update(123, ['FirstName' => 'Hansi']);

// Delete a single resource or multiple resources
Webling::member()->delete(123);
Webling::member()->delete([536, 525]);

  $imageBytes = Webling::member()->image($id, 'photo.jpg', 'mini'); // size: mini|thumb|medium
  $fileBytes = Webling::member()->file($id, 'contract.pdf');
  

  $imageBytes = Webling::article()->image($id, 'image.png', 'thumb');
  

  $fileBytes = Webling::document()->content($id, 'invoice', 'pdf');
  $metadata = Webling::document()->head($id);
  

  $zipBytes = Webling::documentgroup()->archive($id);
  

  $lastUsed = Webling::apikey()->lastUsed($id);
  

  Webling::user()->sendOnboarding($id);
  

$config = Webling::config();
$currentUser = Webling::currentUser();
$definitions = Webling::definitions('simple'); // accepts format: simple|full|zapier
$quota = Webling::quota();
$settings = Webling::settings();

// Update settings
Webling::updateSettings(['theme' => 'dark']);

// Incremental synchronization / change tracking
$changes = Webling::changes(1719710000); // timestamp
$replication = Webling::replicate(123);   // revision ID

$cache = Webling::cached(); // returns Webling\Cache\Cache

// Update the local cache state
$cache->updateCache();

// Fetch a cached object directly
$member = $cache->getObject('member', 123);

use RizwanSarfraz\Webling\Exceptions\WeblingApiException;
use RizwanSarfraz\Webling\Exceptions\WeblingReadonlyException;
use RizwanSarfraz\Webling\Exceptions\WeblingConfigurationException;

try {
    Webling::member()->get(999);
} catch (WeblingApiException $e) {
    echo $e->getStatusCode(); // e.g. 404
    echo $e->getPath();       // e.g. member/999
    echo $e->getMethod();     // e.g. GET
    echo $e->getResponseBody();
} catch (WeblingReadonlyException $e) {
    // Thrown if write is attempted on read-only resources (e.g. letters)
} catch (WeblingConfigurationException $e) {
    // Thrown if domain or API key is missing
}

use Webling\API\Client;
use Webling\API\Response;

$mockClient = Mockery::mock(Client::class);
$mockClient->shouldReceive('get')->with('member/123')->andReturn(new Response(200, '{"id":123}'));

$this->app->instance(Client::class, $mockClient);
bash
php artisan vendor:publish --tag="webling-config"