### Install RabbitLoader PHP SDK via Composer Source: https://rabbitloader.com/kb/setting-up-rabbitloader-on-custom-php-website This command installs the RabbitLoader PHP SDK using Composer. Ensure your PHP version is 5.6 or higher. Composer handles dependency management for the SDK. ```bash composer require rabbit-loader/php-sdk ``` -------------------------------- ### Install and Activate RabbitLoader Package Source: https://rabbitloader.com/kb/installing-rabbitloader-on-a-laravel-website Commands to install the RabbitLoader package via Composer and publish the necessary service provider configuration to the Laravel application. ```bash composer require rabbit-loader/laravel php artisan vendor:publish --provider='RabbitLoader\Laravel\RLServiceProvider' ``` -------------------------------- ### Static Asset Versioning and Cache Purging Source: https://rabbitloader.com/kb/installing-rabbitloader-on-a-laravel-website Techniques for cache busting static assets using query parameters and clearing the entire cache directory via command line. ```html ``` ```bash rm /tmp/rabbitloader/* ``` -------------------------------- ### Configure Middleware and Environment Variables Source: https://rabbitloader.com/kb/installing-rabbitloader-on-a-laravel-website Instructions for registering the RabbitLoader middleware in the Kernel and setting the required license key in the .env file. ```php //app/Http/Kernel.php protected $middleware = [ ... \RabbitLoader\Laravel\Process::class ... ] ``` ```text RABBIT_LOADER_LICENSE_KEY="license key goes here" ``` -------------------------------- ### Exclude JS File from Optimization using Page Rule Source: https://rabbitloader.com/kb/enable-disable-defer-loading-of-javascript This example demonstrates how to exclude a specific JavaScript file ('my-imp-script.js') from being optimized or deferred by RabbitLoader using a Page Rule. Multiple file names can be added, separated by a comma. Exercise caution when excluding files, as dependencies on other deferred JS files can cause website breakage. ```html ``` -------------------------------- ### Define Cache Exclusion Rules Source: https://rabbitloader.com/kb/installing-rabbitloader-on-a-laravel-website Configuring the rabbitloader.php file to define paths and cookies that should be skipped during the optimization and caching process. ```php //skip caching if path starts with admin 'skipPaths' => ['/admin*'], //skip caching if a cookie is found with name cookie1 'skipCookies' => ['cookie1'], ``` -------------------------------- ### Exclude Pages from RabbitLoader Optimization Source: https://rabbitloader.com/kb/setting-up-rabbitloader-on-custom-php-website These PHP examples show how to exclude specific pages or paths from RabbitLoader optimization using the SDK. You can skip caching based on URL patterns or the presence of specific cookies. These calls must precede the `$rlSDK->process()` method. ```php //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(); ``` -------------------------------- ### Exclude JavaScript from Optimization using HTML Attributes Source: https://rabbitloader.com/kb/enable-disable-defer-loading-of-javascript Demonstrates how to prevent RabbitLoader from deferring specific external or inline JavaScript files by adding the 'data-rlskip' attribute to the script tag. ```HTML ``` -------------------------------- ### Integrate RabbitLoader SDK in PHP Website Source: https://rabbitloader.com/kb/setting-up-rabbitloader-on-custom-php-website Integrates the RabbitLoader SDK into your PHP website's entry file (e.g., index.php). It requires loading the Composer autoloader, initializing the SDK with your license key and storage directory, and calling the process method before any output. ```php #1 make sure the composer autolaod file is loaded at the top require_once("/vendor/autoload.php"); #2 integrate RabbitLoader $licenseKey = 'YOUR_LICENSE_KEY'; //get your license key from environment variable $storageDir = '/home/usr/cache-disk/rabbitloader'; //full path storage location where cached files will be stored $rlSDK = new RabbitLoader\SDK\RabbitLoader($licenseKey, $storageDir); $rlSDK->process(); #3 important headers header('Content-Type: text/html; charset=utf-8'); #4 remaining code of the website goes after this ... echo "