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);
$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);