2017 © Pedro PelĂĄez
 

library lumen-theme

Add theming support to your Lumen 5.* projects

image

lukeed/lumen-theme

Add theming support to your Lumen 5.* projects

  • Friday, September 8, 2017
  • by lukeed
  • Repository
  • 3 Watchers
  • 2 Stars
  • 686 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 6 Versions
  • 5 % Grown

The README.md

Lumen Theme

Build Status Latest Stable Version License, (*1)

Add theming support to your Lumen 5.* projects., (*2)

For Laravel support, go to Laravel Theme., (*3)

Features

  • Custom theme locations
  • Support for theme inheritence with theme fallback
  • Theme assets loading
  • Artisan console commands

Install

Require it via terminal like so: ``` bash $ composer require lukeed/lumen-theme, (*4)


Or add the package to your composer file: ``` json "lukeed/lumen-theme": "1.*"

Add a new service provider and optional facade to your bootstrap/app.php file:, (*5)

// Service provider
$app->register(Lukeed\Theme\ThemeServiceProvider::class);

// Facade
class_alias(Lukeed\Theme\Facade\Theme::class, 'Theme');

Configuration

theme.path

Type: string, (*6)

Default: public/themes, (*7)

The path to the themes directory, where all themes should live., (*8)

To change this value, you may either create a custom config/theme.php file and load it inside bootstrap/app.php or you may set the value directly via the config() helper anywhere inside your application., (*9)

// bootstrap/app.php
config(['theme.path' => realpath(base_path('public/custom/path/themes'))]);

OR, (*10)

// config/theme.php
return [
    'path' => realpath(base_path('public/custom/path/themes'))])
];

// bootstrap/app.php
$app->configure('theme');

Creating a Theme

Every theme directory must contain a views folder and a theme.json file, which contains descriptive information about the theme., (*11)

{
    "name": "Theme name",
    "author": "Author Name",
    "description": "Default theme description",
    "version": "1.0",
    "directory": "theme-folder",
    "parent": null
}

The name, author and directory fields are required., (*12)

The directory value must match the name of the theme directory; eg: public/themes/theme-folder., (*13)

If your theme is meant to extend or inherit another theme's views, include the directory name "parent theme" as the parent value; eg: parent-folder., (*14)

View Hierarchy

Given the example:, (*15)

view('home');

The currently active theme will be scanned for a home.blade.php., (*16)

If there is a parent attached to the theme, its directory will be scanned next., (*17)

Lastly, Lumen's view.paths config value will searched. By default, this is resources/views., (*18)

Usage

The theme.path directory will be scanned for all available themes., (*19)

If only one theme is found, it will automatically be selected as the active theme. To manually select a different theme, you may use the set method which accepts a directory value., (*20)

Theme::set('theme-folder');

Then you call views like you usually do in laravel:, (*21)

``` php view('home', []);, (*22)


This will firstly check if there is a home.blade.php in current theme directory. If none is found then it checks parent theme, and finally falls back to default laravel views location. You can also inject theme instance using ThemeInterface. ``` php use lukeed\Theme\Contracts\ThemeInterface; private $theme; public function __construct(ThemeInterface $theme) { $this->theme = $theme }

Available methods

Here's the list of methods you can access:, (*23)

``` php // Activate/set theme Theme::set('theme-namespace');, (*24)

// Get all available themes as an array Theme::all();, (*25)

// Get currently active Theme::get();, (*26)

// Get theme by namespace Theme::get('specific-namespace');, (*27)

// Override default theme path Theme::setDefaultThemePath('new/path/to/themes');, (*28)

// Check if theme exists Theme::has('theme-namespace');, (*29)

// Render theme path URL theme_url('assets/style.css');, (*30)


### Artisan commands Get a table of all found themes: ``` bash $ php artisan theme:list +------------------+-------------+------------+ | Name | Author | Namespace | +------------------+-------------+------------+ | Bootstrap theme | Karlo Mikus | bootstrap | | Default theme | Test Author | default | | Foundation theme | Lorem Ipsum | foundation | | Test theme | Dolor Sitha | test | +------------------+-------------+------------+

Create a theme directory with config file: ``` bash $ php artisan theme:make, (*31)

Template name:, (*32)

Theme name, (*33)

Template author:, (*34)

Firstn Lastn, (*35)

Theme created succesfully! ```, (*36)

Changelog

Please see CHANGELOG for more information what has changed recently., (*37)

TODO

  • Contact me for ideas

The Versions

08/09 2017

dev-master

9999999-dev https://github.com/lukeed/lumen-theme

Add theming support to your Lumen 5.* projects

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Karlo MikuĆĄ
by Luke Edwards

lumen theme templates views

08/09 2017

v1.0.4

1.0.4.0 https://github.com/lukeed/lumen-theme

Add theming support to your Lumen 5.* projects

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Karlo MikuĆĄ
by Luke Edwards

lumen theme templates views

07/03 2016

v1.0.3

1.0.3.0 https://github.com/lukeed/lumen-theme

Add theming support to your Lumen 5.* projects

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Karlo MikuĆĄ
by Luke Edwards

lumen theme templates views

05/03 2016

v1.0.2

1.0.2.0 https://github.com/karlomikus/theme

Add theming support to your Laravel 5.* projects

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Karlo MikuĆĄ

laravel theme views

31/10 2015

v1.0.1

1.0.1.0 https://github.com/karlomikus/theme

Add theming support to your Laravel 5.* projects

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Karlo MikuĆĄ

laravel theme views

21/10 2015

v1.0.0

1.0.0.0 https://github.com/karlomikus/theme

Add theming support to your Laravel 5.* projects

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

The Development Requires

by Karlo MikuĆĄ

laravel theme views