### Install laravel-plausible and publish migrations Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/resources/boost/skills/plausible-development/SKILL.md Install the package, publish its settings migrations, and run migrations. Requires PHP 8.2-8.4, Laravel 11-13, spatie/laravel-settings ^3.0, and spatie/laravel-package-tools ^1.14.0. ```bash composer require jeffersongoncalves/laravel-plausible php artisan vendor:publish --tag="plausible-settings-migrations" php artisan migrate ``` -------------------------------- ### Install laravel-plausible via Composer Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/README.md Install the package via Composer. ```bash composer require jeffersongoncalves/laravel-plausible ``` -------------------------------- ### Publish and run spatie/laravel-settings migrations Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/README.md Publish and run the settings table migration from spatie/laravel-settings if not already done. ```bash php artisan vendor:publish --provider="Spatie\LaravelSettings\LaravelSettingsServiceProvider" --tag="migrations" php artisan migrate ``` -------------------------------- ### Publish and run Plausible settings migrations Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/README.md Publish and run the Plausible settings migration. ```bash php artisan vendor:publish --tag=plausible-settings-migrations php artisan migrate ``` -------------------------------- ### Read and update PlausibleSettings Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/resources/boost/skills/plausible-development/SKILL.md Read and update settings via the `PlausibleSettings` class. Set `domains` and `host_analytics` then call `save()`. ```php use JeffersonGoncalves\Plausible\Settings\PlausibleSettings; $settings = app(PlausibleSettings::class); $settings->domains = 'example.com,blog.example.com'; $settings->host_analytics = 'https://analytics.example.com'; $settings->save(); ``` -------------------------------- ### PlausibleSettings class definition Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/resources/boost/skills/plausible-development/SKILL.md Spatie Settings class with `domains` (nullable string, default null) and `host_analytics` (string, default 'https://plausible.io'). The group is 'plausible'. ```php class PlausibleSettings extends Settings { public ?string $domains = null; public string $host_analytics = 'https://plausible.io'; public static function group(): string { return 'plausible'; } } ``` -------------------------------- ### Package directory structure Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/resources/boost/skills/plausible-development/SKILL.md Directory structure of the package. Shows the service provider, settings class, settings migration, and Blade view locations. ```text src/ PlausibleServiceProvider.php # Package service provider (extends PackageServiceProvider) Settings/ PlausibleSettings.php # Spatie Settings class (group: plausible) database/ settings/ 2026_02_22_000000_create_plausible_settings.php resources/ views/ script.blade.php # Tracking script Blade view ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/README.md Run the package tests. ```bash composer test ``` -------------------------------- ### Pest tests for PlausibleSettings Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/resources/boost/skills/plausible-development/SKILL.md Pest tests for the package: verifies script rendering when domains set, absence when null, default values, and group name. ```php use JeffersonGoncalves\Plausible\Settings\PlausibleSettings; it('renders the tracking script when domains is set', function () { $settings = app(PlausibleSettings::class); $settings->domains = 'example.com'; $settings->save(); $view = $this->blade('@include("plausible::script")'); $view->assertSee('data-domain="example.com"'); $view->assertSee('src="https://plausible.io/js/script.js"'); }); it('does not render the script when domains is null', function () { $settings = app(PlausibleSettings::class); $settings->domains = null; $settings->save(); $view = $this->blade('@include("plausible::script")'); $view->assertDontSee('domains)->toBeNull(); expect($settings->host_analytics)->toBe('https://plausible.io'); }); it('belongs to the plausible group', function () { expect(PlausibleSettings::group())->toBe('plausible'); }); ``` -------------------------------- ### Configure domains setting programmatically Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/README.md Update the 'domains' setting programmatically. The 'domains' setting supports rollup reporting with comma-separated domains. ```php use JeffersonGoncalves\Plausible\Settings\PlausibleSettings; $settings = app(PlausibleSettings::class); $settings->domains = 'example.com'; $settings->save(); ``` -------------------------------- ### Configure host_analytics for self-hosted Plausible Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/README.md Update the 'host_analytics' setting for self-hosted Plausible. The default is 'https://plausible.io'. ```php $settings = app(PlausibleSettings::class); $settings->host_analytics = 'https://analytics.example.com'; $settings->save(); ``` -------------------------------- ### Composer test and analysis commands Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/resources/boost/skills/plausible-development/SKILL.md Composer scripts for testing and code quality: Pest tests, coverage, PHPStan analysis, and Laravel Pint formatting. ```bash composer test # Run Pest tests composer test-coverage # Run with coverage composer analyse # PHPStan static analysis composer format # Laravel Pint formatting ``` -------------------------------- ### Blade tracking script view Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/resources/boost/skills/plausible-development/SKILL.md Blade view that renders the tracking script only when `domains` is not empty. Uses `defer` for non-blocking loading and builds the script src from `host_analytics`. ```blade @php($plausible = app(\JeffersonGoncalves\Plausible\Settings\PlausibleSettings::class)) @if(!empty($plausible->domains)) @endif ``` -------------------------------- ### Include tracking script in Blade layout Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/resources/boost/skills/plausible-development/SKILL.md Include the tracking script in the HTML head. The script only renders when the `domains` setting is not empty. ```blade @include('plausible::script') ``` -------------------------------- ### Include Plausible script in Blade layout Source: https://github.com/jeffersongoncalves/laravel-plausible/blob/master/README.md Include the Plausible script in your Blade layout inside the . The script tag is only rendered when the 'domains' setting is configured. ```blade @include('plausible::script') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.