yaap/theme

Theme support for Laravel 4/5/6 with assets, theme extends etc.

4.1.0 2021-02-07 22:39 UTC

This package is auto-updated.

Last update: 2021-10-08 00:08:50 UTC


README

Inspired by bigecko/laravel-theme. Themes are stored inside default laravel's resources folder

Installation

Require this package in your composer.json:

composer require yaap/theme

Or manually add

"yaap/theme": "4.*"

Optionally, publish config using artisan CLI (if you want to overwrite default config).

php artisan vendor:publish --provider="YAAP\Theme\ThemeServiceProvider"

Package config

	return array(
        'path'          => base_path('resources/themes'),
        'assets_path'   => 'themes',
    );

Theme config

	return array(
        'name'         => 'default',
        'inherit'      => null,
    );

Usage

Structure

├── themes/
    ├── default/
    |   ├── assets/        
        ├── lang/        
        ├── layouts/
        ├── partials/
        ├── views/
        |   └── hello.blade.php
        └── config.php

    └── admin/

    ├── views/
    |   ├── emails/
    |   |   └── notify.blade.php
    |   └── hello.blade.php

├── public/
    └── themes/
		└── default/
			├── css/
			|	└── styles.css
			└── images/
                └── icon.png

Create theme with artisan CLI

The first time you have to create theme "default" structure, using the artisan command:

php artisan theme:create default

In order to seed webpack.mix.js with custom rules add --with-mix option

php artisan theme:create default --with-mix

To delete an existing theme, use the command:

php artisan theme:destroy default

Init theme

Theme::init($name)

This will add to views find path:

  • themes/{$name}
  • themes/{$name}/views

Lang files will be added as well:

  • themes/{$name}/lang

Making view

View::make('hello');
View::make('emails.notify');

Assets

Use laravel mix for assets.

<link rel="stylesheet" href="{{ mix('/themes/default/css/app.min.css') }}"/>
<script type="text/javascript" src="{{ mix('/themes/default/js/app.min.js') }}"></script>

###Blade templates

	@extends('layouts.master')

	@include('partials.header')

	@section('content')

	    <section id="main">
	        <h1>HOME</h1>
	    </section>
	@stop

	@include('partials.footer')

###Fallback capability

You still able to use default View::make('emails.notify') which is stored outside the themes directory

Can I hire you guys?

Yes! Say hi: hello@hexide-digital.com
We will be happy to work with you! Other work we’ve done

Follow us

Stay up to date with the latest Vuestic news! Follow us on LinkedIn or Facebook

License

MIT license.