rabbit-loader/php-sdk

PHP SDK for optimizing websites with RabbitLoader

v1.0.8 2024-08-13 06:24 UTC

This package is auto-updated.

Last update: 2024-09-13 06:30:07 UTC


README

RabbitLoader PHP SDK can be used to speed up any website that is built using core PHP or frameworks.

Highlights

  • πŸš€ Boost PageSpeed Insights Score for all pages of the custom developed website
  • πŸ—οΈ Automatically reduce image size by ~40% by converting to NextGen AVIF and WebP formats
  • ➰ Lazy load below-the-fold images and YouTube videos
  • πŸ“± Reduce CSS size by 98% automatically by generating critical-css for fastest rendering of the webpage
  • ✨ Improve all Core Web Vitals metrics (lower FCP, FID, and CLS)
  • ⚑️ Higher rankings on Google Search and better conversions due to page speed optimization and healthy Core Web Vitals metrics
  • 🌐 Cache and serve static assets (CSS/JS/Images) via inbuilt premium CDN
  • ♾️ HTTP/3 Full request and response multiplexing of static assets
  • πŸ—œοΈ Use Brotli compression for static assets transfer and loading

Installation

composer require rabbit-loader/php-sdk

Example

Example use, assuming index.php is the file that handles all traffic for the website.

Public page example

#load vendor/autoload.php

#integrate RabbitLoader
$licenseKey = 'YOUR_LICENSE_KEY'; //get your license key from environment variable
$storageDir = '/cache-disk/rabbitloader'; //storage location where cached files will be stored
$rlSDK = new RabbitLoader\SDK\RabbitLoader($licenseKey, $storageDir);
$rlSDK->process();

#remaining code of the website goes after this ...
echo "<h1>Hello World!</h1>"

Admin page example

When a content is modified from admin panel, this can be called to make the cache stale.

#admin.php

$urlModified = 'https://mywebsite.com/modified-page-slug/';
$rlSDK->onContentChange($urlModified);

#if home page needs to be purged too, then-
$rlSDK->onContentChange('https://mywebsite.com/');

Skipping some pages from caching and optimization

//skip caching if path starts with admin
$rlSDK->skipForPaths(['/admin*']);

//skip caching if a cookie is found with name cookie1 
$rlSDK->skipForCookies(['cookie1']);

//all the above options should come before the process() call
$rlSDK->process();

More Samples and License Key

A license key is required to run the SDK. This guide has more code samples and explains how to get the license key.

Support

Contact RabbitLoader team here.