Theme management for laravel 5

v1.0.1 2018-05-17 08:02 UTC

This package is not auto-updated.

Last update: 2020-07-11 05:18:27 UTC


This is a theme management package for PenCMS. You can easily integrate this package with any Laravel based project.


  • Custom theme location
  • Ceparation frontend & backend
  • Unlimited Parent view finding
  • Multiple theme config extension
  • Multiple theme changelog extension
  • Artisan console commands
  • Translate


Install it via Composer. Run this command in your terminal from your project directory:

composer require vdhoangson/pencms-theme

Wait for a while, Composer will automatically install in your project.


Call this package service in config/app.php config file. To do that, add this line in app.php in providers array:


Now run this command in your terminal to publish this package resources:

php artisan vendor:publish --provider="vdhoangson\Theme\ThemeServiceProvider"

Artisan Command

Run this command in your terminal from your project directory.

Create a theme directory:

php artisan theme:create place theme_name

place : frontend or backend

theme_name : Theme Name

 What is theme description? []:

 What is theme author name? []:

 What is theme version? []:

List of all themes:

php artisan theme:list

| Place   | Name    | Author     | Version |
| backend | default | vdhoangson | 1.0     |

Example folder structure:

- app/
- ..
- ..
- public/
    - themes/
        - default/
            - assets
                - css
                - img
                - js
            - views/
                - layouts
            - changelog.json        
            - theme.json

You can change theme.json and changelog.json name from config/theme.php

// ..
'config' => [
    'name' => 'theme.json',
    'changelog' => 'changelog.json'
// ..

Set theme using middleware

Use VSThemeFront for Frontend

Route::group(['prefix' => 'frontend', 'middleware'=>'VSThemeFront'], function() {
    // Theme will be applied.

Use VSThemeBack for Backend

Route::group(['prefix' => 'backend', 'middleware'=>'VSThemeBack'], function() {
    // Theme will be applied.

API List


For switching current theme you can use setTheme method.



For getting current theme details you can use getTheme method:

Theme::getTheme(); // return Array

You can also get particular theme details:

Theme::getTheme('theme-name'); // return Array
Theme::getTheme('theme-name', true); // return Collection


Retrieve current theme's name:

Theme::currentTheme(); // return string


Retrieve all theme information:

Theme::all(); // return Array


For getting whether the theme exists or not:

Theme::exists(); // return bool


For info about the specified theme:

$themeInfo = Theme::themeInfo('theme-name'); // return Collection

$themeName = $themeInfo->get('name');
// or
$themeName = $themeInfo['name'];

Also fallback support:

$themeInfo = Theme::themeInfo('theme-name'); // return Collection

$themeName = $themeInfo->get('changelog.versions');
// or
$themeName = $themeInfo['changelog.versions'];

// or you can also call like as multi dimension
$themeName = $themeInfo['changelog']['versions'];


For binding theme assets you can use the assets method:

Theme::assets('asset_path'); // return string

When using helper you can also get assets path:

vassets('asset_path'); // return string

Add asset to html:

<link rel="stylesheet" href="{{ vassets('style.css') }}">


You can translate language by vtrans method:

When using helper you can also get assets path:

vtrans('your_file.your_key'); // return string