2017 © Pedro Peláez
 

library theme-manager

A simple theme manager

image

monkblog/theme-manager

A simple theme manager

  • Sunday, December 27, 2015
  • by ericdowell
  • Repository
  • 1 Watchers
  • 0 Stars
  • 75 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 16 Versions
  • 0 % Grown

The README.md

A simple theme manager that can be used with Laravel 5., (*1)

Circle CI StyleCI Code Climate Test Coverage Total Downloads Latest Stable Version Latest Unstable Version License, (*2)

Requirements

  • Use with Laravel requires version 5 or above.
  • PHP 5.5.9 or greater

Installation

Require this package with Composer, (*3)

composer require monkblog/theme-manager 1.1.*

Show me the examples already!!

examples.php, (*4)

Documentation

Requiring Theme Meta Data Field(s)

This package requires that a theme.yml/theme.yaml file have at least a name field defined., (*5)

As of version 1.1 you can define a list of required fields that need to be defined in each theme.yml file. This package will handle and separate the invalid themes from the valid ones., (*6)

Go to config/theme-manager.php and change required_fields to the array of required field(s) to be enforced. (see Publish Config section if config is not in your config folder)., (*7)

Injecting Required Field(s) into Starter Class

If you're not using the Laravel Service Provider, you can pass an array to the \ThemeManager\Starter start() method:, (*8)

$basePath = null;
$requiredFields = [ 'display_name', 'version', 'license', ];

$starter = ( new \ThemeManager\Starter )->start( $basePath, $requiredFields );

$themeManager = new \ThemeManager\ThemeManager( $starter );

You may also use the helper function as a shortcut:, (*9)

$themeManager = theme_manager( null, [ 'display_name', 'version', 'license', ] );

Error Handling

As of version 1.1 there's a boolean $exceptionOnInvalid which by default is false. To have the package throw exceptions for invalid themes change exception_on_invalid in config/theme-manager.php to be true or pass true as the $exceptionOnInvalid argument on the start method of \ThemeManager\Starter class., (*10)

Folder Structure

This package assumes that you have a themes folder at the root of your project containing all your theme folders., (*11)

The 'base path' can be overwritten via config/theme-manager.php or the start( __DIR__ . '/folder/' ) method on the \ThemeManager\Starter class, (*12)

e.g., (*13)

# themes/my-theme/theme.yml
name: my-theme
  • app/
  • public/
  • themes/
    • my-theme/
    • theme.yml
    • my-theme-with-autoload/
    • composer.json
    • helpers.php
    • src/
      • MyThemeNamespace/
      • MyClass.php
      • MyThemeServiceProvider.php
    • theme.yml
    • vendor/
    • my-other-theme/
    • theme.yml
  • vendor/

Bootstrapping Theme Classes

Bootstrapping theme Service Provider(s) or other important classes before the application runs:, (*14)

For Laravel users: this code snippet is probably best placed at the bottom of bootstrap/autoload.php, (*15)

( new \ThemeManager\Starter )->bootstrapAutoload();

OR, (*16)

theme_manager_starter()->bootstrapAutoload();

You can also optionally pass in a path to your themes folder if it's different than the default:, (*17)

theme_manager_starter()->bootstrapAutoload( '/path/to/theme-folder' );

Using with Laravel

Once Composer has installed or updated your packages, you need to register ThemeManager with Laravel. Go into your config/app.php, find the providers key and add:, (*18)

'ThemeManager\ServiceProvider',

You can add the ThemeManager Facade, to have easier access to the ThemeManager globally:, (*19)

'ThemeManager' => 'ThemeManager\Facade\ThemeManager',

Usages:

ThemeManager::all();
ThemeManager::getAllThemeNames();

ThemeManager::themeExists( 'theme-name' );
$theme = ThemeManager::getTheme( 'theme-name' );
$themeName = $theme->getName();

Publish Config

Run:, (*20)

php artisan vendor:publish --tag=theme

Override the base themes path:

(See Publish Config section if theme-manager.php isn't present), (*21)

Go to config/theme-manager.php and change the base_path to the folder you want to use., (*22)

<?php

return [

    'base_path' => __DIR__ . '/../path/to/themes-folder',

    //Other config stuff
    ...
];

Adding more Themes folder to Manager

If you have a secondary themes folder you can add all of the themes to the ThemeManager by using:, (*23)

ThemeManager::addThemeLocation( base_path( '/path/to/alternative/themes-folder' ) );

License

This package is open-sourced software licensed under the MIT license., (*24)

The Versions

27/12 2015

1.1.x-dev

1.1.9999999.9999999-dev

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme simple manager themes theme manager monk monkblog simple theme manager

27/12 2015

dev-master

9999999-dev

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme simple manager themes theme manager monk monkblog simple theme manager

07/09 2015

v1.1.2

1.1.2.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme simple manager themes theme manager monk monkblog simple theme manager

07/09 2015

v1.1.1

1.1.1.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme simple manager themes theme manager monk monkblog simple theme manager

17/08 2015

v1.1.0

1.1.0.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme simple manager themes theme manager monk monkblog simple theme manager

17/08 2015

v1.1-beta2

1.1.0.0-beta2

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme simple manager themes theme manager monk monkblog simple theme manager

10/08 2015

v1.1-beta1

1.1.0.0-beta1

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme manager theme manager monk monkblog

03/08 2015

1.0.x-dev

1.0.9999999.9999999-dev

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme manager theme manager monk monkblog

03/08 2015

v1.0.7

1.0.7.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme manager theme manager monk monkblog

02/08 2015

v1.0.6

1.0.6.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme manager theme manager monk monkblog

28/06 2015

v1.0.5

1.0.5.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme manager theme manager monk monkblog

28/06 2015

v1.0.4

1.0.4.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme manager theme manager monk monkblog

28/06 2015

v1.0.3

1.0.3.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme manager theme manager monk monkblog

28/06 2015

v1.0.2

1.0.2.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme manager theme manager monk monkblog

28/06 2015

v1.0.1

1.0.1.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell

laravel theme manager theme manager monk monkblog

28/06 2015

v1.0

1.0.0.0

A simple theme manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eric Dowell