Skip to content

Configuration Guide 🛠️

Welcome to the configuration guide for the Laravel Driver.js package! In this guide, we'll walk you through the various configuration options available to customize the behavior of Laravel Driver.js in your Laravel application.

Publishing the Config

The configuration file is published to config/driverjs.php when you run php artisan driverjs:install. You can also publish it manually:

bash
php artisan vendor:publish --tag=driverjs-config

Driver.js Version 📦

By default, the package loads Driver.js v1.4.0 from the jsDelivr CDN. You can pin to a specific version or use latest to always get the newest release:

php
'version' => env('DRIVERJS_VERSION', '1.4.0'),

Set the DRIVERJS_VERSION environment variable to override this without modifying the config file directly.

Asset Source 🌐

This option controls how the Driver.js CSS and JavaScript assets are loaded. Supported values: "cdn", "npm", or "custom".

php
'asset_source' => env('DRIVERJS_ASSET_SOURCE', 'cdn'),
ValueDescription
cdnLoads assets from jsDelivr CDN. No build step required.
npmExpects you to install driver.js via npm/pnpm/yarn and bundle it with Vite. Asset directives and renderAssetLinks() return an empty string in this mode.
customYou manage asset inclusion yourself. The package will not inject any scripts or stylesheets.

CDN URL Overrides 🔗

If you want to use a custom CDN or self-hosted files, you can override the default CDN URLs:

php
'cdn_js_url' => env('DRIVERJS_CDN_JS_URL', null),
'cdn_css_url' => env('DRIVERJS_CDN_CSS_URL', null),

When set to null, the package will use the default jsDelivr URLs based on the configured version above.

Default Driver Configuration ⚙️

These options define the global defaults for every Driver.js instance created through the package. You can override any of these at runtime using the fluent builder methods.

php
'defaults' => [
    'animate' => true,
    'overlay_color' => '#000',
    'overlay_opacity' => 0.7,
    'smooth_scroll' => false,
    'allow_close' => true,
    'overlay_click_behavior' => 'close',
    'stage_padding' => 10,
    'stage_radius' => 5,
    'allow_keyboard_control' => true,
    'disable_active_interaction' => false,
],
OptionDefaultDescription
animatetrueAnimate transitions between tour steps
overlay_color'#000'Overlay color (any valid CSS color)
overlay_opacity0.7Overlay opacity (0.0 to 1.0)
smooth_scrollfalseSmooth scroll to highlighted elements
allow_closetrueAllow closing by clicking overlay or pressing Escape
overlay_click_behavior'close'Action on overlay click: "close", "nextStep", or a JavaScript callback
stage_padding10Padding (px) between element and cutout
stage_radius5Border radius (px) of the cutout
allow_keyboard_controltrueEnable keyboard navigation (Escape, Arrow keys)
disable_active_interactionfalseDisable clicking the highlighted element

Default Popover Configuration 💬

These options control the appearance and behaviour of the popover that appears alongside each highlighted element.

php
'popover' => [
    'class' => '',
    'offset' => 10,
    'show_buttons' => ['next', 'previous', 'close'],
    'disable_buttons' => [],
    'show_progress' => false,
    'progress_text' => '{{current}} of {{total}}',
    'next_btn_text' => 'Next →',
    'prev_btn_text' => '← Previous',
    'done_btn_text' => 'Done',
],
OptionDefaultDescription
class''Custom CSS class on the popover wrapper
offset10Distance (px) between popover and element
show_buttons['next', 'previous', 'close']Buttons to display
disable_buttons[]Buttons to visually disable (greyed out)
show_progressfalseShow "X of Y" progress indicator
progress_text' of 'Progress text template
next_btn_text'Next →'Next button label
prev_btn_text'← Previous'Previous button label
done_btn_text'Done'Done button label (shown on last step)

Tour Storage Configuration 💾

When a user completes a tour, the package can remember this so the tour is not shown again on subsequent visits.

php
'storage' => [
    'driver' => env('DRIVERJS_STORAGE_DRIVER', 'session'),
    'key_prefix' => 'driverjs_tour_',
    'cache_store' => env('DRIVERJS_CACHE_STORE', null),
],
DriverDescriptionPersistence
sessionStores in Laravel sessionUntil browser closes
cacheStores in Laravel cacheConfigurable TTL (default: 1 year)
databaseStores in database tablePermanent (until reset)
nullDisables trackingN/A

When using the cache driver, you can specify which cache store to use via the DRIVERJS_CACHE_STORE environment variable. When set to null, the default cache store is used.

When using the database driver, you'll need to publish and run the migration:

bash
php artisan vendor:publish --tag=driverjs-migrations
php artisan migrate

Route Middleware 🔒

The package registers one internal HTTP route for tour completion tracking. By default it carries no extra middleware. You can protect it using the route_middleware option:

php
'route_middleware' => env('DRIVERJS_ROUTE_MIDDLEWARE', null),

Examples:

php
// Require the web middleware stack (session, CSRF)
'route_middleware' => 'web',

// Require authentication (recommended with the database storage driver)
'route_middleware' => ['web', 'auth'],

// No middleware (default)
'route_middleware' => null,

Set the environment variable to avoid modifying the config file directly:

dotenv
DRIVERJS_ROUTE_MIDDLEWARE=web,auth

When using the database storage driver, always add auth middleware so that anonymous requests do not attempt to record completions (they would silently fail since there is no auth()->id() to associate with).

That's it! You now have the knowledge to fine-tune the Laravel Driver.js package to suit your specific needs. Happy configuring! 🛠️