PHPackages                             akbardwi/laratheme - 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. akbardwi/laratheme

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

akbardwi/laratheme
==================

Theme and asset management for laravel

1.1.4(7mo ago)032CC-BY-3.0PHP

Since Sep 15Pushed 7mo ago1 watchersCompare

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

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

Laravel-Laratheme
=================

[](#laravel-laratheme)

[![Latest Stable Version](https://camo.githubusercontent.com/eb33561dfc8569f08fd0d43f2490b7c4a4789e72a72a9b06f06ca22690a410f1/68747470733a2f2f6170692e7472617669732d63692e6f72672f616b6261726477692f6c6172617468656d652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/akbardwi/laratheme)[![Latest Stable Version](https://camo.githubusercontent.com/202f3b2c60a13e8034de0b0da8b8ab5873751276121ca27ab293cc3a24aa7dd5/68747470733a2f2f706f7365722e707567782e6f72672f616b6261726477692f6c6172617468656d652f762f737461626c65)](https://packagist.org/packages/akbardwi/laratheme)[![Latest Unstable Version](https://camo.githubusercontent.com/c18a0c90c497ff600ee1038079bd89ac629385f45800458d3720cb50202b5888/68747470733a2f2f706f7365722e707567782e6f72672f616b6261726477692f6c6172617468656d652f762f756e737461626c65)](https://packagist.org/packages/akbardwi/laratheme)[![License](https://camo.githubusercontent.com/05b82eb0be7467e8c23a1ad0a1d90a032666339aa17bf81bd2590d61a9299328/68747470733a2f2f706f7365722e707567782e6f72672f616b6261726477692f6c6172617468656d652f6c6963656e7365)](https://packagist.org/packages/akbardwi/laratheme)

Laratheme is a Laravel theme and asset management package. You can easily integrate this package with any Laravel based project.

### Features

[](#features)

- Custom theme path
- Override theme
- Parent theme support
- Unlimited Parent view finding
- Asset Finding
- Theme translator support
- Multiple theme config extension
- Multiple theme changelog extension
- Artisan console commands
- Theme enable only Specific route via middleware
- Almost everything customizable
- Also Laravel 5.5 to Laravel 10 Supported

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

[](#installation)

Laratheme is a Laravel package so you can install it via Composer. Run this command in your terminal from your project directory:

```
composer require akbardwi/laratheme
```

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

Configuration
-------------

[](#configuration)

Below **Laravel 5.5** you have to call this package service in `config/app.php` config file. To do that, add this line in `app.php` in `providers` array:

```
Akbardwi\Laratheme\Providers\LarathemeServiceProvider::class,
```

Below **Laravel 5.5** version to use facade you have to add this line in `app.php` to the `aliases` array:

```
'Theme' => Akbardwi\Laratheme\Facades\Theme::class,
```

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

```
php artisan vendor:publish --provider="Akbardwi\Laratheme\Providers\LarathemeServiceProvider"

```

Artisan Command
---------------

[](#artisan-command)

Run this command in your terminal from your project directory.

Create a theme directory:

```
php artisan theme:create your_theme_name

 What is theme title?:
 >

 What is theme description? []:
 >

 What is theme author name? []:
 >

 What is theme version? []:
 >

 Any parent theme? (yes/no) [no]:
 > y

 What is parent theme name?:
 >
```

List of all themes:

```
php artisan theme:list

+----------+---------------------+---------+----------+
| Name     | Author              | Version | Parent   |
+----------+---------------------+---------+----------+
| themeone | Akbar Dwi Syahputra | 1.1.0   |          |
| themetwo | Akbar Dwi Syahputra | 1.0.0   | themeone |
+----------+---------------------+---------+----------+
```

Example folder structure:
-------------------------

[](#example-folder-structure)

```
- app/
- ..
- ..
- themes/
    - themeone/
        - assets
            - css
                - app.css
            - img
            - js
        - lang
            - en
                -content.php
        - views/
            - layouts
                - master.blade.php
            - welcome.blade.php
        - changelog.yml
        - theme.json
     - themetwo/

```

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

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

`json`, `yml`, `yaml`, `php`, `ini`, `xml` extension supported.

For example:

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

Then run `theme:create` command which describe above.

Now Please see the API List Doc.

View Finding Flow:
------------------

[](#view-finding-flow)

Suppose you want find `welcome.blade.php`

```
 - At first check your active theme
 - If `welcome.blade.php not found in active theme then search parent recursively
 - If `welcome.blade.php not found in parents theme then search laravel default view folder resources/views

```

API List
--------

[](#api-list)

- [set](https://github.com/akbardwi/laratheme#set)
- [get](https://github.com/akbardwi/laratheme#get)
- [current](https://github.com/akbardwi/laratheme#current)
- [all](https://github.com/akbardwi/laratheme#all)
- [has](https://github.com/akbardwi/laratheme#has)
- [getThemeInfo](https://github.com/akbardwi/laratheme#getThemeInfo)
- [assets](https://github.com/akbardwi/laratheme#assets)
- [lang](https://github.com/akbardwi/laratheme#lang)

### set

[](#set)

For switching current theme you can use `set` method.

```
Theme::set('theme-name');
```

### get

[](#get)

For getting current theme details you can use `get` method:

```
Theme::get(); // return Array
```

You can also get particular theme details:

```
Theme::get('theme-name'); // return Array
```

```
Theme::get('theme-name', true); // return Collection
```

### current

[](#current)

Retrieve current theme's name:

```
Theme::current(); // return string
```

### all

[](#all)

Retrieve all theme information:

```
Theme::all(); // return Array
```

### has

[](#has)

For getting whether the theme exists or not:

```
Theme::has(); // return bool
```

### getThemeInfo

[](#getthemeinfo)

For info about the specified theme:

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

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

Also fallback support:

```
$themeInfo = Theme::getThemeInfo('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'];
```

### assets

[](#assets)

For binding theme assets you can use the `assets` method:

```
Theme::assets('your_asset_path'); // return string
```

It's generated at `BASE_URL/theme_roots/your_active_theme_name/assets/your_asset_path`

If `your_asset_path` does not exist then it's find to active theme immediate parent assets folder. Look like `BASE_URL/theme_roots/your_active_theme_parent_name/assets/your_asset_path`

When using helper you can also get assets path:

```
themes('your_asset_path'); // return string
```

If you want to bind specific theme assets:

```
Theme::assets('your_theme_name:your_asset_path'); // return string
// or
themes('your_theme_name:your_asset_path'); // return string
```

**Suppose you want to bind `app.css` in your blade. Then below code can be applicable:**

```

```

Specific theme assets:

```

```

### lang

[](#lang)

The `lang` method translates the given language line using your current **theme** [localization files](https://laravel.com/docs/master/localization):

```
echo Theme::lang('content.title'); // return string
// or
echo lang('content.title'); // return string
```

also support

```
echo Theme::lang('content.title', [your replace array], 'your desire locale'); // return string
// or
echo lang('content.title', [your replace array], 'your desire locale'); // return string
```

If you want to bind specific theme assets:

```
echo Theme::lang('your_theme_name::your_asset_path'); // return string
// or
echo lang('your_theme_name::your_asset_path'); // return string
```

How to use in Route
-------------------

[](#how-to-use-in-route)

```
Route::get('/', function () {
    Theme::set('your_theme_name');
    return view('welcome');
});
```

***This will firstly check if there is a welcome.blade.php in current theme directory. If none is found then it checks parent theme, and finally falls back to default Laravel views location.***

If you want to specific theme view:

```
Route::get('/', function () {
    Theme::set('your_theme_name');
    return view('your_theme_name::welcome');
});
```

Set theme using route middleware
--------------------------------

[](#set-theme-using-route-middleware)

A helper middleware is included out of the box if you want to define a theme per route. To use it:

First register it in app\\Http\\Kernel.php:

```
protected $routeMiddleware = [
    // ...
    'theme' => \Akbardwi\Laratheme\Middleware\RouteMiddleware::class,
];
```

Now you can apply the middleware to a route or route-group. Eg:

```
Route::group(['prefix' => 'admin', 'middleware'=>'theme:Your_theme_name'], function() {
    // ... Add your routes here
    // The Your_theme_name will be applied.
});
```

Set theme using web middleware
------------------------------

[](#set-theme-using-web-middleware)

A helper middleware is included out of the box if you want to define a theme per route. To use it:

First register it in app\\Http\\Kernel.php:

```
protected $middlewareGroups = [
    'web' => [
        // ...
        \Akbardwi\Laratheme\Middleware\WebMiddleware::class,
    ],
    // ...
];
```

Theme set from `config/theme.php` .

Then in your controller you can call your view as you would normally do:

```
return view('home');  // This will load the home.blade.php from the the folder you set in your `config/theme.php`
```

### Dependency Injection

[](#dependency-injection)

You can also inject theme instance using ThemeContract, eg:

```
use Akbardwi\Laratheme\Contracts\ThemeContract;

private $theme;

public function __construct(ThemeContract $theme)
{
    $this->theme = $theme
}
```

Troubleshooting
---------------

[](#troubleshooting)

Clear config after runing `vendor publish` (see [Config section](#configuration)) to save issues related to config caching by running:

`php artisan config:cache`

`php artisan config:clear`

Credits
-------

[](#credits)

- [Shipu Ahamed](https://github.com/Shipu)
- [Akbar Dwi Syahputra](https://github.com/akbardwi)
- [All Contributors](../../contributors)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance69

Regular maintenance activity

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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 ~65 days

Recently: every ~95 days

Total

7

Last Release

210d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b9f38b56d7bfd395eb69b0e8c9dd8713559d7130410d0f5294ae32c927fd30d?d=identicon)[akbardwi](/maintainers/akbardwi)

---

Top Contributors

[![akbardwi](https://avatars.githubusercontent.com/u/11191442?v=4)](https://github.com/akbardwi "akbardwi (13 commits)")

---

Tags

laravellumenthememanagementmultiassetchild-themelaratheme

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/akbardwi-laratheme/health.svg)

```
[![Health](https://phpackages.com/badges/akbardwi-laratheme/health.svg)](https://phpackages.com/packages/akbardwi-laratheme)
```

###  Alternatives

[shipu/themevel

Theme and asset management for laravel

34632.1k1](/packages/shipu-themevel)[laraveljutsu/zap

A flexible, performant, and developer-friendly schedule management system for Laravel

1.4k69.1k](/packages/laraveljutsu-zap)[david-griffiths/nova-dark-theme

A dark theme for Laravel Nova

71576.9k](/packages/david-griffiths-nova-dark-theme)[laracrafts/laravel-url-shortener

Powerful URL shortening tools in Laravel

97110.7k](/packages/laracrafts-laravel-url-shortener)[orchestra/asset

Asset Component for Orchestra Platform

52177.4k4](/packages/orchestra-asset)[sbine/simple-tenancy

Simple Laravel multi-tenancy in the same database

373.4k](/packages/sbine-simple-tenancy)

PHPackages © 2026

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