Fireboost SDK

The current recommended way to interact with the Fireboost API is by using our official PHP SDK. We are actively working on expanding our libraries support to include JavaScript and Python libraries in the near future.

Fireboost PHP SDK Usage

The Fireboost PHP SDK allows you to easily interact with the Fireboost API using PHP.

Installation

Install the SDK via Composer:

composer require fireboostio/fireboost-php-sdk

Usage

Authentication is handled internally by the SDK — you only need to call the read or write methods, and the SDK will securely manage the API communication for you.

use FireboostIO\SDK\CacheManager;
use FireboostIO\SDK\Adapter\SessionAdapter;

// Create a CacheManager instance with default SessionAdapter
$apiKey = 'your-api-key'; // Or set FIREBOOST_API_KEY environment variable
$cacheManager = new CacheManager(new SessionAdapter(), $apiKey);

// Save data to cache
$cacheKey = 'example/key';
$content = ['name' => 'Example', 'value' => 123];
$isPublic = true; // Set to true for publicly accessible cache
$response = $cacheManager->saveCache($cacheKey, $content, $isPublic);

// Read data from cache
$data = $cacheManager->readCache($cacheKey);

// Read public data (no authentication required)
$publicData = $cacheManager->readPublicCache($cacheKey);

// Delete data from cache
$cacheManager->deleteCache($cacheKey);

// Get cache usage statistics
$stats = $cacheManager->getStatistics();

Adapters

The SDK supports multiple adapters for storing the JWT token. By default, it uses the SessionAdapter, but you can swap it out with a custom implementation if needed.

Session adapter (Default)
use FireboostIO\SDK\Adapter\SessionAdapter;

$adapter = new SessionAdapter();
// Or with custom session keys:
$adapter = new SessionAdapter('custom_token_key', 'custom_login_attempts_key');
Redis Adapter
// With default Redis connection
$adapter = new RedisAdapter();

// Or with custom Redis connection
$redis = new \Redis();
$redis->connect('redis-server.example.com', 6379);
$adapter = new RedisAdapter($redis, 'custom:token:key:', 'custom:login:attempts:', 3600);
Database Adapter
use FireboostIO\SDK\Adapter\DatabaseAdapter;

$pdo = new PDO('mysql:host=localhost;dbname=myapp', 'username', 'password');
$adapter = new DatabaseAdapter($pdo, 'custom_tokens_table', 'user_identifier');
File Adapter
use FireboostIO\SDK\Adapter\FileAdapter;

// With default system temp directory
$adapter = new FileAdapter();

// Or with custom storage directory
$adapter = new FileAdapter('/path/to/storage', 'token_filename', 'login_attempts_filename');

Creating Your Own Custom Adapter

You can create your own custom adapter by implementing the TokenStorageAdapterInterface. This allows you to store JWT tokens and login attempt counters in any storage system of your choice.

Custom Adapter
namespace YourNamespace;

use FireboostIO\SDK\Adapter\TokenStorageAdapterInterface;

class CustomAdapter implements TokenStorageAdapterInterface
{
    // Your storage mechanism (e.g., a custom database connection, API, etc.)
    private $storage;

    public function __construct($storage)
    {
        $this->storage = $storage;
    }

    /**
     * Store a JWT token
     */
    public function storeToken(string $token): bool
    {
        // Implement token storage logic
        // Return true if successful, false otherwise
        return true;
    }

    /**
     * Retrieve the stored JWT token
     */
    public function getToken(): ?string
    {
        // Implement token retrieval logic
        // Return the token or null if not found
        return $storedToken ?? null;
    }

    /**
     * Clear the stored JWT token
     */
    public function clearToken(): bool
    {
        // Implement token clearing logic
        // Return true if successful, false otherwise
        return true;
    }

    /**
     * Check if a token is stored
     */
    public function hasToken(): bool
    {
        // Implement token existence check
        // Return true if a token exists, false otherwise
        return !empty($this->getToken());
    }

    /**
     * Increment the login attempt counter
     */
    public function incrementLoginAttempt(): int
    {
        // Implement login attempt increment logic
        // Return the new count
        return $newCount;
    }

    /**
     * Get the current login attempt count
     */
    public function getLoginAttemptCount(): int
    {
        // Implement login attempt count retrieval logic
        // Return the current count
        return $currentCount;
    }

    /**
     * Reset the login attempt counter to 0
     */
    public function resetLoginAttemptCount(): bool
    {
        // Implement login attempt reset logic
        // Return true if successful, false otherwise
        return true;
    }
}

// Then use your custom adapter with the CacheManager
$customAdapter = new CustomAdapter($yourStorageMechanism);
$cacheManager = new CacheManager($customAdapter, $apiKey);

The Fireboost PHP SDK is designed to be simple and developer-friendly — just install, configure your token, and start making secure API calls with minimal setup.

Official libraries

fireboostio/fireboost-php-sdk

PHP SDK - for Fireboost.io includes both authentication and client libraries.

fireboostio/fireboost-php-auth

Library - for authentication only.

fireboostio/fireboost-php-client

Library - for interacting with Fireboost.io

Coming Soon

We will be adding libraries for other languages in the future.

  • JavaScript/Node.js
  • Python

Stay tuned for updates on our Fireboost.io GitHub repository or join our Slack community to be notified when new SDKs are released.

Was this page helpful?