PHPackages                             nwidart/themify - 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. [Framework](/categories/framework)
4. /
5. nwidart/themify

ActiveLibrary[Framework](/categories/framework)

nwidart/themify
===============

Add basic theme functionality to a Laravel application.

483[1 issues](https://github.com/nWidart/Themify-l5/issues)PHP

Since Feb 10Pushed 11y ago2 watchersCompare

[ Source](https://github.com/nWidart/Themify-l5)[ Packagist](https://packagist.org/packages/nwidart/themify)[ RSS](/packages/nwidart-themify/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Themify
===============

[](#laravel-themify)

Themify is a Laravel package that provides basic theme functionality in a non-obtrusive way. The purpose of Themify is to allow the developer to group views inside themes, having each theme its own folder. If you have experience with Yii framework theming, you will find this package usage very familiar.

A sample structure folder could be like this:

```
app/
├── Http
├── ...
├── themes
│   ├── admin
│   │   ├── category
│   │   ├── dashboard
│   │   ├── ...
│   └── default
│       ├── index.blade.php
│       ├── layouts
│       ├── post
│       └── ...

```

Themify expects you to store your themes in a given folder, which is `app/themes` by default. Then, each theme should have its own views inside its folder, just like it was a `views` folder.

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

[](#installation)

- Use composer to install the package:

```
composer require nwidart/themify=*

```

- Add the ServiceProvider to your service provider list inside `app/config/app.php`:

```
'providers' => array(
    ...
    'Illuminate\View\ViewServiceProvider',
    'Illuminate\Workbench\WorkbenchServiceProvider',

    'Nwidart\Themify\ThemifyServiceProvider',
),
```

- Add the Facade to your aliases array inside `app/config/app.php`:

```
'aliases' => array(
    ...
    'URL'             => 'Illuminate\Support\Facades\URL',
    'Validator'       => 'Illuminate\Support\Facades\Validator',
    'View'            => 'Illuminate\Support\Facades\View',

    'Themify'         => 'Nwidart\Themify\Facades\Themify',
),
```

- Create your `themes` directory inside your application. By default, **Themify** expects an `app/themes` directory, but this can be modified in the package configuration.
- Publish package configuration with artisan:

```
php artisan vendor:publish

```

Then, modify settings as needed by editing `config/themify.php`.

Usage
-----

[](#usage)

First, you have to tell the package which theme you want to use. You have three different ways to do this, ordered by priority:

1. Calling `Themify::set($theme)`. Being `theme` the name of the folder of the theme you want to use.
2. Defining a `public $theme` property in your controller.
3. Using `Themify::defaults($theme)`, which is a shortcut to changing the `themify::default_theme` property in package settings.

Once you have defined your theme, you can render your views using the `View` class in the traditional way. **Themify** will try to find the specified view inside the defined theme folder. If it doesn't find it, it will fallback to the default `views` folder (or whatever you have defined in your `app/config/view.php`).

`View::render('foo', compact($bar));`

### Priorities

[](#priorities)

Each of the mentioned methods has an internal priority assigned:

- If the theme is explicitly set using `Themify::set($theme)`, the only way to override it is to use `set()` again.
- If no calls to `set()` are found, **Themify** will check for a `$theme` property in the current controller (if any). Note that this property should be `public`. This check is made through a simple `before` filter that the ServiceProvider of the package adds to all routes.

```
