### Access MatomoSettings via DI and app container Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/resources/boost/skills/matomo-development/SKILL.md Shows two ways to access MatomoSettings: dependency injection (recommended, singleton) and the app container. The example retrieves site_id and host_analytics properties. ```php use JeffersonGoncalves\Matomo\Settings\MatomoSettings; // Via dependency injection (recommended -- singleton) public function show(MatomoSettings $settings) { return $settings->site_id; } // Via app container $settings = app(MatomoSettings::class); $host = $settings->host_analytics; $siteId = $settings->site_id; ``` -------------------------------- ### Install Laravel Matomo via Composer Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/README.md Install the package via Composer. ```bash composer require jeffersongoncalves/laravel-matomo ``` -------------------------------- ### Update and save Matomo settings Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/resources/boost/skills/matomo-development/SKILL.md Updates all five Matomo settings properties and saves them. The example sets domains, host_analytics, site_id, file, and script values. ```php $settings = app(MatomoSettings::class); $settings->domains = 'example.com'; $settings->host_analytics = 'analytics.example.com'; $settings->site_id = '1'; $settings->file = 'matomo.php'; $settings->script = 'matomo.js'; $settings->save(); ``` -------------------------------- ### Run Database Migration Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/README.md Run the migration to create the settings table. ```bash php artisan migrate ``` -------------------------------- ### Package structure overview Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/resources/boost/skills/matomo-development/SKILL.md Shows the package directory layout, including the settings class, service provider, Blade view, and migration file. ```text src/ Settings/MatomoSettings.php # Settings class with 5 tracking properties MatomoServiceProvider.php # Service provider (auto-discovered) resources/views/ script.blade.php # Matomo tracking JavaScript snippet database/settings/ 2026_01_01_000000_create_matomo_settings.php # Settings migration ``` -------------------------------- ### Publish and run Matomo settings migration Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/resources/boost/skills/matomo-development/SKILL.md Publish the settings migration and run it. This creates 5 settings in the `settings` database table under the `matomo` group. ```bash php artisan vendor:publish --tag=matomo-settings-migrations php artisan migrate ``` -------------------------------- ### Run Tests with Composer Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/README.md Run the package's test suite. ```bash composer test ``` -------------------------------- ### Publish Matomo Settings Migration Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/README.md Publish the settings migration for the package. ```bash php artisan vendor:publish --tag=matomo-settings-migrations ``` -------------------------------- ### Run Pest tests with php vendor/bin/pest Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/resources/boost/skills/matomo-development/SKILL.md Command to execute the package's test suite using Pest, which is set up with Orchestra Testbench. Run this from the package root directory. ```bash php vendor/bin/pest ``` -------------------------------- ### Create Filament settings page for Matomo Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/resources/boost/skills/matomo-development/SKILL.md Create a Filament settings page to manage Matomo settings stored in the database via spatie/laravel-settings. The form defines fields for domains, host, site ID, tracker endpoint, and JavaScript file, with defaults matching the package's configuration table. ```php use Filament\Forms\Components\TextInput; use Filament\Pages\SettingsPage; use JeffersonGoncalves\Matomo\Settings\MatomoSettings; class ManageMatomoSettings extends SettingsPage { protected static string $settings = MatomoSettings::class; protected static ?string $navigationIcon = 'heroicon-o-chart-bar'; public function form(Form $form): Form { return $form->schema([ TextInput::make('domains') ->label('Tracked Domains') ->placeholder('example.com') ->helperText('Leave empty to disable tracking'), TextInput::make('host_analytics') ->label('Matomo Host') ->placeholder('analytics.example.com') ->required(), TextInput::make('site_id') ->label('Site ID') ->default('1') ->required(), TextInput::make('file') ->label('Tracker Endpoint') ->default('matomo.php') ->required(), TextInput::make('script') ->label('JavaScript File') ->default('matomo.js') ->required(), ]); } } ``` -------------------------------- ### Pest tests for matomo::script blade rendering Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/resources/boost/skills/matomo-development/SKILL.md Two Pest test cases verify that the matomo script blade view renders with the configured host analytics, site ID, and PRG parameters when domains are set, and does not render the tracking script when domains are empty. The tests use the MatomoSettings model from the package. ```php use JeffersonGoncalves\Matomo\Settings\MatomoSettings; it('renders matomo script when domains is set', function () { $settings = app(MatomoSettings::class); $settings->domains = 'example.com'; $settings->host_analytics = 'analytics.example.com'; $settings->site_id = '1'; $settings->file = 'matomo.php'; $settings->script = 'matomo.js'; $settings->save(); $view = $this->blade("@include('matomo::script')"); $view->assertSee('analytics.example.com'); $view->assertSee('setSiteId'); }); it('does not render when domains is empty', function () { $settings = app(MatomoSettings::class); $settings->domains = ''; $settings->save(); $view = $this->blade("@include('matomo::script')"); $view->assertDontSee('_paq'); }); ``` -------------------------------- ### Update Matomo Settings via Code Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/README.md Update Matomo settings programmatically. All settings are stored in the database via spatie/laravel-settings, allowing runtime configuration without .env files. ```php use JeffersonGoncalves\Matomo\Settings\MatomoSettings; $settings = app(MatomoSettings::class); $settings->domains = 'example.com'; $settings->site_id = '1'; $settings->host_analytics = 'analytics.example.com'; $settings->file = 'matomo.php'; $settings->script = 'matomo.js'; $settings->save(); ``` -------------------------------- ### MatomoSettings class definition Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/resources/boost/skills/matomo-development/SKILL.md Defines the MatomoSettings class extending Spatie\LaravelSettings\Settings. It declares five public string properties and a group() method returning 'matomo'. ```php namespace JeffersonGoncalves\Matomo\Settings; use Spatie\LaravelSettings\Settings; class MatomoSettings extends Settings { public string $domains; public string $site_id; public string $file; public string $script; public string $host_analytics; public static function group(): string { return 'matomo'; } } ``` -------------------------------- ### Include Matomo Tracking Script in Blade Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/README.md Add the tracking script to your Blade layout, typically before the closing head tag. ```php @include('matomo::script') ``` -------------------------------- ### Matomo tracking script output Source: https://github.com/jeffersongoncalves/laravel-matomo/blob/master/resources/boost/skills/matomo-development/SKILL.md This is the HTML output generated by the matomo::script view when settings are configured. It includes the Matomo tracking code with automatic page view and link tracking enabled. ```html ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.