Laravel pattern lets admins update SEO and analytics settings without redeployment
A developer building the 'Kickoff' Laravel starter kit has shared a pattern for managing SEO metadata and analytics credentials through an admin UI, eliminating the need to edit environment files or redeploy the app. The approach stores settings like Google Analytics 4 and Tag Manager IDs in a database using Spatie's laravel-settings package, then overlays them onto Laravel's config system at boot time via AppServiceProvider. This ensures all views read exclusively from config(), creating a single, consistent data path and avoiding conflicts between database and config sources. A try-catch block in the boot process allows the app to fall back gracefully to .env defaults if the settings table does not yet exist, preventing failures on fresh installs. Input validation enforces correct ID formats before saving, and conditional rendering automatically suppresses analytics snippets when no ID is configured, keeping local development traffic out of production analytics.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in