PHP code example of dominservice / laravel-theme-helper

1. Go to this page and download the library: Download dominservice/laravel-theme-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dominservice / laravel-theme-helper example snippets


use Dominservice\LaravelThemeHelper\Facades\Theme;

Theme::meta()
    ->setTitle('DSO-IT', config('app.name'))
    ->setDescription('Software house and custom web systems')
    ->setCanonical(url()->current())
    ->setAuthor('Domin Software')
    ->setGenerator('DomiPress')
    ->setHttpEquiv('X-UA-Compatible', 'IE=edge')
    ->setIcons([
        'favicon' => asset('favicon.ico'),
        'manifest' => asset('site.webmanifest'),
        'theme_color' => '#0f172a',
    ]);

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

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

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

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' => [],
    ],
];

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

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();

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',
            ],
        ],
    ],
]);

$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);

$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);

$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();

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

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

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,
]);

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,
]);

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();
bash
php artisan vendor:publish --tag=config