lightgear / theme by ralf57

Easy theme Management for Laravel 4
72
9
2
Package Data
Maintainer Username: ralf57
Maintainer Contact: ralf57@gmail.com (Donato Rotunno)
Package Create Date: 2013-10-06
Package Last Update: 2014-03-23
Language: PHP
License: Unknown
Last Refreshed: 2024-11-19 03:10:39
Package Statistics
Total Downloads: 72
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 9
Total Watchers: 2
Total Forks: 1
Total Open Issues: 0

Drop-in theme support for Laravel 4

Overview

The Lightgear Theme package adds support for themes to a Laravel 4 application.

Features

  • Views overrides for both app and packages
  • Theme assets (css, less and js) support via Lightgear Asset package

Installation

Via Laravel 4 Package Installer

php artisan package:install lightgear/theme

Manual

Just require

"lightgear/theme": "dev-master"

in your composer.json and run

composer update

Then register the service provider

'Lightgear\Asset\ThemeServiceProvider'

and, optionally, the alias

'Theme' => 'Lightgear\Theme\Facades\Theme'

in app/config/app.php

Important: regardless of the installation method, until I find a better way to handle this, make sure to have the ThemeServiceProvider as the last registered or, at least, after the service providers containing the views you want to override.
This is needed in order to override the packages' views.

Usage

First create the directory that will contain your themes. By default this is "themes" located in the application root but this can be changed in the config file. A tipical theme structure would be:


themes
  |__mytheme
     |__css/
     |__less/
     |__js/
     |__views/
     |__info.php

As you notice each theme must have an info.php file with the following contents:


return array(
    'name' => 'My theme',
    'description' => 'A good desc',
    'author' => 'Donato Rotunno',
    'version' => 1.0,
    'styles' => array(
        'paths' => array(
            'less',
            'css'
        ),
        'package' => 'mytheme',
        'group' => 'frontend' // optional asset group
    ),
    'scripts' => array(
        'paths' => array(
            'js',
        ),
        'package' => 'mytheme',
        'group' => 'frontend' // optional asset group
    ),
);

This is a pretty simple structure. For more information about the theme assets, please refer to Lightgear Asset documentation.

Views overrides

To override any views (be it from app or package) just create the corresponding file in the views directory.
For example, to override the view package::posts.index just create the file views/package/posts/index.php. The same goes with the views located in the app. The view posts.index would be overridden in views/posts/index.php.

Configuration

Both the themes directory and the active theme can be set in the config file.

Changelog

0.5: initial release