Blog Detail

20

Jun
Write Beautiful API Integrations & SDKs in PHP with Saloon cover image

arrow_back Write Beautiful API Integrations & SDKs in PHP with Saloon

Saloon offers a fluent, object-oriented pattern to build your next API integration or PHP SDK. It makes sharing API requests throughout your application a breeze. You don’t have to configure an HTTP client, so you can start sending requests really quickly.

The Saloon has it out of the box alongside many other useful tools like OAuth2 boilerplate and caching if you need to request faking for your tests. If you use Laravel, there’s also a dedicated Laravel package with artisan console commands to help you build even faster.

Features

  • Simple, easy-to-learn syntax that standardizes the way you interact with APIs
  • Abstract API integrations into classes so you can keep your code DRY
  • Configuration is fast and can be shared across all your requests
  • Framework agnostic
  • Mocking requests for testing
  • Great for building your own PHP SDKs
  • Authentication & OAuth2 boilerplate already built for you
  • Scalable with lots of API integrations across many team members

Why Saloon?

Building API integrations can be time-consuming. After you have found an API client to use, you’re faced with lots of configuration to remember and it’s hard to repeat requests without copying and pasting, and then when you introduce patterns like OAuth2 everything gets complicated. You’ll often find yourself writing the same boilerplate code over and over again.

We’ve standardized the way we talk to APIs with PSR-7 and PSR-18 but we haven’t got a standard structure to build API integrations.

Saloon aims to solve this.

Installation

To start with Saloon, you must install it through Composer.

If you are building an SDK or a package with Saloon, it’s recommended that you use the standard PHP version.
If you are using Laravel, you can install the saloon-laravel package which installs Saloon and also provides you with Artisan commands to help you get up and running quickly, as well as better testing functionality.

composer require sammyjo20/saloon-laravel

Example

<?php

use App\Http\Saloon\Requests\GetForgeServerRequest;

$request = new GetForgeServerRequest(serverId: '123456');

$response = $request->send();
$data = $response->json();

This package has various features and methods available. Saloon provides many pre-written plugins to save you from manually defining headers and config variables for common use cases. If you want to dig more about this package, you can visit its complete documentation here.

If you want to build any custom web application, CRM Software, SAAS Application, or eCommerce application then Codebrisk is here to help you. We have built an exquisite team of expert Laravel developers who share our passion. Our combined knowledge and experience ensure smooth onboarding, a quick start, and satisfying results. And it covers both small and large IT projects according to your needs. We are open to any type of contract and are always happy to explain any complexities. So if you have a great idea, please feel free to contact us or start a project with us.

Published at : 20-06-2022

Author : Rizwan Aslam
AUTHOR
Rizwan Aslam

I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.

Launch your project

Launch project