PHPackages                             dominservice/laravel-theme-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dominservice/laravel-theme-helper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dominservice/laravel-theme-helper
=================================

A small Laravel utility to manage everything you usually put into the &lt;head&gt; and the closing of &lt;body&gt;, plus a pragmatic Schema.org JSON‑LD generator.

3.1.0(1mo ago)07MITPHPPHP ^8.1

Since Oct 28Pushed 1mo agoCompare

[ Source](https://github.com/dominservice/laravel-theme-helper)[ Packagist](https://packagist.org/packages/dominservice/laravel-theme-helper)[ Docs](https://github.com/dominservice/laravel-theme-helper)[ RSS](/packages/dominservice-laravel-theme-helper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (8)Used By (0)

Dominservice Laravel Theme Helper
=================================

[](#dominservice-laravel-theme-helper)

![Packagist](https://camo.githubusercontent.com/5a73574ebfa6a7be34de907a54bcb482ebe4b67b2e6406bd7459991a7b5c1da8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646f6d696e736572766963652f6c61726176656c2d7468656d652d68656c7065722e737667)[![Latest Version](https://camo.githubusercontent.com/70b4ca523eeb8e6f8d1d22712a301c71877c2b444b9bbcc7e63efd0106ed59f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f646f6d696e736572766963652f6c61726176656c2d7468656d652d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://github.com/dominservice/laravel-theme-helper/releases)[![Total Downloads](https://camo.githubusercontent.com/87eedb4a7dfae04c62c29e517ea9c1640e52c4887f62e07ddf4bd6b347bddd05/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646f6d696e736572766963652f6c61726176656c2d7468656d652d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dominservice/laravel-theme-helper)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

A Laravel package for:

- SEO and meta management,
- asset registration and rendering,
- breadcrumb and hreflang support,
- JSON-LD / Schema.org generation,
- sitemap and `robots.txt` generation helpers,
- responsive image rendering with `picture` / AVIF / WebP / fallback support,
- schema presets for common company and CMS pages,
- theme registry and active theme selection,
- public/admin theme context handling,
- asset resolution for `mix`, `vite`, and static builds,
- theme discovery through `theme.json` manifests.

It is designed to be the integration layer between your Laravel application and one or more frontend themes, while still providing the usual `` and `` helpers.

---

Table of contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Quick start](#quick-start)
- [Theme system](#theme-system)
    - [Contexts](#contexts)
    - [Theme config](#theme-config)
    - [Theme discovery with `theme.json`](#theme-discovery-with-themejson)
    - [Drivers](#drivers)
    - [Theme switching](#theme-switching)
- [Structured data](#structured-data)
    - [Multiple schema types on one page](#multiple-schema-types-on-one-page)
    - [Schema collection API](#schema-collection-api)
    - [Schema presets](#schema-presets)
- [Sitemap](#sitemap)
- [Robots.txt](#robotstxt)
- [Responsive images](#responsive-images)
- [API](#api)
- [Blade integration](#blade-integration)
- [Helpers](#helpers)
- [Deployment notes](#deployment-notes)
- [Testing](#testing)
- [License](#license)

---

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10.x / 11.x / 12.x / 13.x
- `spatie/schema-org`
- Optional: `mcamara/laravel-localization`

---

Installation
------------

[](#installation)

```
composer require dominservice/laravel-theme-helper
```

Optional hreflang integration:

```
composer require mcamara/laravel-localization
```

Publish config if you want to define themes globally:

```
php artisan vendor:publish --tag=config
```

This publishes:

- `config/theme-helper.php`

---

Quick start
-----------

[](#quick-start)

```
use Dominservice\LaravelThemeHelper\Facades\Theme;

Theme::meta()
    ->setTitle('DSO-IT', config('app.name'))
    ->setDescription('Software house and custom web systems')
    ->setCanonical(url()->current());

Theme::assets()->useTheme('public');

echo Theme::renderHead();
echo Theme::renderBodyEnd();
```

Switch public theme dynamically:

```
Theme::useTheme('public-metronic', 'public');
Theme::assets()->useTheme('public');
```

---

Theme system
------------

[](#theme-system)

### Contexts

[](#contexts)

The package supports theme contexts.

Typical usage:

- `admin`
- `public`

Rules are application-defined, but a common setup is:

- admin always uses a fixed admin theme
- public can use one of many declared themes

### Theme config

[](#theme-config)

Published config structure:

```
return [
    'contexts' => [
        'admin' => [
            'default_theme' => 'admin',
        ],
        'public' => [
            'default_theme' => 'public',
        ],
    ],

    'themes' => [
        'admin' => [
            'label' => 'Admin',
            'context' => 'admin',
            'driver' => 'static',
            'layout' => null,
            'view_path' => null,
            'entries' => [
                'css' => [],
                'js' => [],
            ],
            'meta' => [],
        ],
    ],

    'discovery' => [
        'enabled' => false,
        'manifest_filename' => 'theme.json',
        'scan_paths' => [],
    ],
];
```

### Theme discovery with `theme.json`

[](#theme-discovery-with-themejson)

The package can discover themes from one or more directories. This lets you keep your application-defined themes in config while also supporting uploaded or shipped themes described by a manifest.

Example config:

```
'discovery' => [
    'enabled' => true,
    'manifest_filename' => 'theme.json',
    'scan_paths' => [
        resource_path('themes'),
        base_path('themes'),
    ],
],
```

Example `theme.json`:

```
{
  "key": "classic",
  "label": "Classic",
  "context": "public",
  "driver": "mix",
  "layout": "themes.classic.layouts.app",
  "view_path": "resources/views/themes/classic",
  "manifest_path": "public/themes/classic/mix-manifest.json",
  "deploy_target": "public/themes/classic",
  "entries": {
    "css": ["themes/classic/app.css"],
    "js": ["themes/classic/app.js"]
  },
  "description": "Base public theme",
  "version": "1.0.0",
  "author": {
    "name": "Domin Software"
  },
  "settings": {
    "supports_upload": true
  }
}
```

If a theme key already exists in config, config has priority over discovered manifests. This makes discovery safe for local overrides.

### Drivers

[](#drivers)

Supported asset drivers:

- `static`
- `mix`
- `vite`

### Theme switching

[](#theme-switching)

```
Theme::useTheme('public-metronic', 'public');
Theme::useTheme('admin', 'admin');

$theme = Theme::currentTheme('public');
$layout = $theme->layout();
$driver = $theme->driver();
$description = $theme->description();
$previewImage = $theme->previewImage();
```

---

Structured data
---------------

[](#structured-data)

### Multiple schema types on one page

[](#multiple-schema-types-on-one-page)

Google supports multiple structured data items on the same page when they describe user-visible content on that page. This is useful for pages that need more than one schema type at once, for example:

- `Organization`
- `WebSite`
- `WebPage`
- `BreadcrumbList`
- `Product`
- `Service`
- `FAQPage`

This package supports that pattern through `@graph`.

Simple example:

```
echo Theme::structuredGraph([
    [
        '@type' => 'Organization',
        'name' => 'Domin Software',
        'url' => 'https://example.com',
    ],
    [
        '@type' => 'WebPage',
        'name' => 'CRM systems',
        'url' => 'https://example.com/crm',
    ],
    [
        '@type' => 'BreadcrumbList',
        'itemListElement' => [
            [
                '@type' => 'ListItem',
                'position' => 1,
                'name' => 'Home',
                'item' => 'https://example.com',
            ],
        ],
    ],
]);
```

### Schema collection API

[](#schema-collection-api)

```
$schemas = Theme::schemaCollection()
    ->organization([
        'name' => 'Domin Software',
        'url' => 'https://example.com',
    ])
    ->product([
        'name' => 'CMS Starter',
    ])
    ->service([
        'name' => 'CRM implementation',
        'serviceType' => 'Custom CRM development',
    ]);

echo Theme::structuredGraph($schemas);
```

This lets you output one graph that contains separate entities for organization data, product data, services, breadcrumbs or page-level metadata.

### Schema presets

[](#schema-presets)

For common business pages you often want a repeatable graph instead of building every entity manually.

Available preset keys:

- `organization`
- `website`
- `home_page`
- `web_page`
- `service_page`
- `product_page`
- `faq_page`

Example:

```
$schemas = Theme::schemaPreset('service_page', [
    'organization' => [
        'name' => 'Domin Software',
        'url' => 'https://example.com',
        'logo' => 'https://example.com/logo.png',
    ],
    'web_page' => [
        'name' => 'CRM systems',
        'url' => 'https://example.com/crm',
        'description' => 'Custom CRM systems for companies',
    ],
    'service' => [
        'name' => 'CRM implementation',
        'serviceType' => 'Custom CRM development',
    ],
    'breadcrumbs' => [
        ['@type' => 'ListItem', 'position' => 1, 'name' => 'Home', 'item' => 'https://example.com'],
        ['@type' => 'ListItem', 'position' => 2, 'name' => 'CRM', 'item' => 'https://example.com/crm'],
    ],
]);

echo Theme::structuredGraph($schemas);
```

---

Sitemap
-------

[](#sitemap)

The package includes a builder for XML sitemaps. It supports:

- standard `urlset`,
- `sitemapindex`,
- image sitemap extensions,
- alternate locale URLs through `xhtml:link`,
- configurable default `changefreq` and `priority`.

Example:

```
$xml = Theme::sitemap()
    ->addUrl('https://example.com/', [
        'lastmod' => now(),
        'changefreq' => 'daily',
        'priority' => '1.0',
        'alternates' => [
            ['hreflang' => 'pl-PL', 'href' => 'https://example.com/'],
            ['hreflang' => 'en-US', 'href' => 'https://example.com/en'],
        ],
        'images' => [
            [
                'loc' => 'https://example.com/storage/hero.webp',
                'title' => 'Homepage hero image',
            ],
        ],
    ])
    ->renderUrlset();
```

For sitemap indexes:

```
$index = Theme::sitemap()
    ->addSitemap('https://example.com/sitemap-pages.xml')
    ->addSitemap('https://example.com/sitemap-blog.xml')
    ->renderIndex();
```

---

Robots.txt
----------

[](#robotstxt)

The package also includes a builder for `robots.txt`.

Example:

```
$robots = Theme::robots()
    ->addGroup('*', allow: ['/'], disallow: ['/admin', '/login'])
    ->addSitemap('https://example.com/sitemap.xml')
    ->setHost('example.com')
    ->render();
```

---

Responsive images
-----------------

[](#responsive-images)

The package includes a small renderer for SEO-friendly responsive images with modern formats.

Example using explicit `` nodes:

```
echo Theme::images()->picture([
    [
        'type' => 'image/avif',
        'srcset' => asset('themes/classic/img/about.avif'),
        'media' => '(min-width: 768px)',
    ],
    [
        'type' => 'image/webp',
        'srcset' => asset('themes/classic/img/about.webp'),
    ],
], [
    'src' => asset('themes/classic/img/about.jpg'),
    'alt' => 'About section visual',
    'width' => 1400,
    'height' => 1040,
]);
```

Or using a simpler format map:

```
echo Theme::images()->pictureFromFormats([
    'avif' => asset('themes/classic/img/about.avif'),
    'webp' => asset('themes/classic/img/about.webp'),
    'jpg' => asset('themes/classic/img/about.jpg'),
], [
    'alt' => 'About section visual',
    'width' => 1400,
    'height' => 1040,
]);
```

---

API
---

[](#api)

Main facade methods:

```
Theme::meta();
Theme::assets();
Theme::breadcrumbs();
Theme::hreflang();
Theme::sitemap();
Theme::robots();
Theme::schemaPreset('home_page', [...]);
Theme::images();
Theme::registry();
Theme::contexts();
Theme::currentTheme('public');
Theme::useTheme('classic', 'public');
Theme::structured([...]);
Theme::schemaCollection();
Theme::structuredGraph([...]);
Theme::renderHead();
Theme::renderBodyEnd();
```

---

Blade integration
-----------------

[](#blade-integration)

```

    {!! Theme::renderHead() !!}

    @yield('content')

    {!! Theme::renderBodyEnd() !!}

```

---

Helpers
-------

[](#helpers)

Available helpers:

- `theme_structured_data(array $data, array $options = [])`
- `theme_structured_graph(array $schemas, array $options = [])`
- `theme_sitemap()`
- `theme_robots()`
- `theme_schema_preset(string $preset, array $data = [])`
- `theme_picture(array $sources, array $imgAttributes = [], array $pictureAttributes = [])`
- `theme_current_theme(string $context = 'public')`
- `theme_current_layout(string $context = 'public')`
- `theme_use(string $themeKey, ?string $context = null)`

---

Deployment notes
----------------

[](#deployment-notes)

Theme definitions can now also carry:

- `build_config_path`
- `manifest_path`
- `hot_file_path`
- `deploy_target`
- `source_path`
- `preview_image`
- `settings`

This makes the package a good base for future theme upload, import/export and theme management panels without forcing a specific storage model today.

---

Testing
-------

[](#testing)

Run package tests:

```
vendor/bin/phpunit
```

---

License
-------

[](#license)

MIT

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance92

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~39 days

Total

7

Last Release

39d ago

Major Versions

1.1.2 → 2.0.12025-10-29

2.0.1 → 3.0.02026-04-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d67c041316385020aafb7eef9f11971d6fad80a11a44f4078273bda6890722d?d=identicon)[dominservice](/maintainers/dominservice)

---

Top Contributors

[![dominservice](https://avatars.githubusercontent.com/u/13433147?v=4)](https://github.com/dominservice "dominservice (1 commits)")

---

Tags

laravelJSON-LDthemeseometa

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dominservice-laravel-theme-helper/health.svg)

```
[![Health](https://phpackages.com/badges/dominservice-laravel-theme-helper/health.svg)](https://phpackages.com/packages/dominservice-laravel-theme-helper)
```

###  Alternatives

[artesaos/seotools

SEO Tools for Laravel and Lumen

3.3k5.1M60](/packages/artesaos-seotools)[honeystone/laravel-seo

SEO metadata and JSON-LD package for Laravel.

34744.1k](/packages/honeystone-laravel-seo)[vaersaagod/seomate

SEO, mate! It's important.

4341.6k2](/packages/vaersaagod-seomate)[lionix/seo-manager

SEO Manager for Laravel Framework

2165.4k](/packages/lionix-seo-manager)[fomvasss/laravel-meta-tags

A package to manage SEO (meta-tags, xml-fields, etc.)

3028.9k](/packages/fomvasss-laravel-meta-tags)[calotype/seo

A package containing SEO helpers.

722.6k](/packages/calotype-seo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
