PHPackages                             bagosii/laravel-theme - 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. [Templating &amp; Views](/categories/templating)
4. /
5. bagosii/laravel-theme

ActiveLibrary[Templating &amp; Views](/categories/templating)

bagosii/laravel-theme
=====================

Laravel 5 Themes: Asset &amp; Views folder per theme. Theme inheritance. Blade integration and more...

v1.0.6(11y ago)127MITPHPPHP &gt;=5.4.0

Since Feb 26Pushed 10y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (9)Used By (0)

Description
-----------

[](#description)

[![Laravel](https://camo.githubusercontent.com/fefa73cbcb138f313755edeb816d67030c8ca82a24371d2c30c4605f1a1d6b86/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e302d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](http://laravel.com)[![License](https://camo.githubusercontent.com/30597ff9a350144f03bffdd9183e16468e0b3ca1193e1d08591d992622738d55/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://tldrlegal.com/license/mit-license)[![Downloads](https://camo.githubusercontent.com/bf9e6f5fd35335e192a0588b48ae439e270ab0e501ca6aadef9ec483abea08be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696761737465722f6c61726176656c2d7468656d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/igaster/laravel-theme)

This is a package for the Laravel 5 Framework that adds basic support for managing themes. It allows you to seperate your views &amp; your assets files in seperate folders, and supports for theme extending! Awesome :)

Features:

- Views &amp; Asset seperation in theme folders
- Theme inheritence: Extend any theme and create Theme hierarcies (WordPress style!)
- Intergrates [Orchestra/Asset](http://orchestraplatform.com/docs/3.0/components/asset) to provide Asset dependencies managment
- Your App &amp; Views remain theme-agnostic. Include new themes with (almost) no modifications

How it works
------------

[](#how-it-works)

Very simple, you create a folder for each Theme in 'resources/views' and keep all your views seperated. The same goes for assets: create a folder for each theme in your 'public' directory. Set your active theme and you are done. The rest of your application remains theme-agnostic©, which means that when you `View::make('index')` you will access the `index.blade.php` from your selected theme's folder. Same goes for your assets.

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

[](#installation)

Edit your project's `composer.json` file to require:

```
"require": {
    "bagosii/laravel-theme": "~1.0"
}

```

and install with `composer update`

Add the service provider in `app/config/app.php`, `Providers` array:

```
'bagosii\laravelTheme\themeServiceProvider',

```

also edit the `Facades` array and add:

```
'Theme'  => 'bagosii\laravelTheme\Facades\Theme',

```

Almost Done. You only need to publish configuration file to your application with

```
artisan vendor:publish

```

That's it. You are now ready to start theming your applications!

Defining themes
---------------

[](#defining-themes)

Simple define your themes in the `themes` array in `config\theme.php`. The format for every theme is very simple:

```
// Select a name for your theme
'theme-name' => [

    // Theme to extend
    // Defaults to null (=none)
    'extends'	 	=> 'theme-to-extend',

    // The path where the view are stored
    // Defaults to 'theme-name'
    // It is relative to /resources/views (or what ever is defined in )
    'views-path' 	=> 'path-to-views',

    // The path where the assets are stored
    // Defaults to 'theme-name'
    // It is relative to /public
    'asset-path' 	=> 'path-to-assets',   // defaults to: theme-name

    // you can add your own custom keys and retreive them with Theme::config('key')
],
```

all settings are optional and can be ommited. Check the example in the configuration file... If you are OK with the defaults then you don't even have to touch the configuration file. If a theme is not found then the default values will be used (Convention over configuration)

Extending themes
----------------

[](#extending-themes)

You can set a theme to extend an other. When you are requesting a view/asset that doesn't exist in your active theme, then it will be resolved from it's parent theme. You can easily create variations of your theme by simply overiding your views/themes that are different.

All themes fall back to the default laravel folders if a resource is not found on the theme folders. So for example you can leave your common libraries (jquery/bootstrap ...) in your `public` folder and use them from all themes. No need to dublicate common assets for each theme!

Working with Themes
-------------------

[](#working-with-themes)

The default theme can be configured in the `theme.php` configuration file. Working with themes is very straightforward. Use:

```
Theme::set('theme-name');    // switch to 'theme-name'
Theme::get();                // retreive current theme's name
Theme::config('key');        // read current theme's configuration value for 'key'
```

For example this is a Service Provider that will select a different theme for the `/admin/xxx` urls:

```
class themeSelectServiceProvider extends ServiceProvider {

    public function boot()
    {
        if (\Request::segment(1)=='admin')
            \Theme::set('adminTheme');
    }

}
```

...or you can use a middleware to apply a theme to a `Route::group()` etc. For more advanced example check demo application: [Set Theme in Session](https://github.com/igaster/laravel-theme-demo)

Building your views
-------------------

[](#building-your-views)

Whenever you need to link to a local file (image/css/js etc) you can retreive its path with:

```
Theme::url('path-to-file')
```

The path is relative to Theme Folder (NOT to pubic!). For example, if you have placed an image in `public\theme-name\img\logo.png` your Blade code would be:

```

```

When you are refering to a local file it will be looked-up in the current theme hierarcy, and the correct path will be returned. If the file is not found on the current theme or its parents then an exception will be thrown.

Some usefull helpers you can use:

```
Theme::js('file-name')
Theme::css('file-name')
Theme::img('src','alt', 'class-name')
```

Assets Managment (Optional)
---------------------------

[](#assets-managment-optional)

This package provides intergration with [Orchestra/Asset](http://orchestraplatform.com/docs/3.0/components/asset) component. All the features are explained in the official documentation. Although Orchestra/Asset is installed along with this package, **it's use is optional.**

To use the Orchestra\\Asset you need to add in your Providers array:

```
'Orchestra\Asset\AssetServiceProvider',
'Orchestra\Html\HtmlServiceProvider',

```

and add the Asset facade in your `Facades` array in `app/config/app.php`

```
'Asset' => 'Orchestra\Support\Facades\Asset',

```

Now you can leverage all the power of Orchestra\\Asset package. However the syntax can become quite cumbersome when you are using Themes + Orchestra/Asset, so some Blade-specific sugar has been added to ease your work. Here how to build your views:

In any blade file when you need to refer to a script or css: (dont use single/double quotes)

```
@css(filename)
@js(filename)

```

Please note that you are just defining your css/js files but not actually dumping them in html. Usually you only need write your css/js decleration in one place on the Head/Footer of you page. So open your master layout and place:

```
{!! Asset::styles() !!}
{!! Asset::scripts() !!}

```

exactly where you want write your declerations.

Assets dependencies
-------------------

[](#assets-dependencies)

This is an [Orchestra/Asset](http://orchestraplatform.com/docs/3.0/components/asset) feature explained well in the official documentation. Long story short:

```
@css (filename, alias, depends-on)
@js  (filename, alias, depends-on)

```

and your assets dependencies will be auto resolved. Your assets will be exported in the correct order. The biggest benefit of this approach is that you don't have to move all your declerations in your master layout file. Each sub-view can define it's requirements and they will auto-resolved in the correct order with no doublications. Awesome! A short example:

```
@js  (jquery.js,    jq)
@js  (bootstrap.js, bs, jq)

```

Important Note:
---------------

[](#important-note)

Laravel is compiling your views every-time you make an edit. A compiled view will not recompile unless you make any edit to your view. Keep this in mind while you are developing themes...

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 71% 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 ~4 days

Total

8

Last Release

4068d ago

Major Versions

v0.9 → v1.02015-02-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/0dfe7d36bc1874ece2c244e52f38fe85b7c1ca08b54a1441743fd87f6c32121a?d=identicon)[bagosii](/maintainers/bagosii)

---

Top Contributors

[![igaster](https://avatars.githubusercontent.com/u/4586319?v=4)](https://github.com/igaster "igaster (44 commits)")[![bagosii](https://avatars.githubusercontent.com/u/12140965?v=4)](https://github.com/bagosii "bagosii (18 commits)")

---

Tags

packagebladelaravel 5assetsthemesviews

### Embed Badge

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

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

###  Alternatives

[igaster/laravel-theme

Laravel Themes: Asset &amp; Views folder per theme. Theme inheritance. Blade integration and more...

5161.2M12](/packages/igaster-laravel-theme)

PHPackages © 2026

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