1. Go to this page and download the library: Download apisutra/laravel 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/ */
apisutra / laravel example snippets
use App\Sdk\CatalogClient;
use App\Sdk\GetProduct;
$client = app(CatalogClient::class);
$product = $client->send(new GetProduct(42))->dataOrFail();
use App\Sdk\CatalogClient;
use App\Sdk\GetProduct;
use ApiSutra\Laravel\Facades\ApiSutra;
use ApiSutra\Testing\MockResponse;
$catalog = ApiSutra::for(CatalogClient::class);
$catalog->fake([GetProduct::class => MockResponse::success(['id' => 42])]);
$this->getJson('/products/42')->assertOk();
$catalog->assertSent(GetProduct::class, times: 1);
use ApiSutra\Laravel\Queue\ReleaseOnSdkThrottle;
public function middleware(): array
{
return [new ReleaseOnSdkThrottle()];
}
use ApiSutra\Laravel\Observability\Events\ExecutionCompleted;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
Event::listen(ExecutionCompleted::class, static function (ExecutionCompleted $event): void {
Log::info('SDK operation completed', $event->snapshot->data);
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.