mikelmi / mks-theme
Theme support for Laravel
v2.1
2017-02-20 15:26 UTC
Requires
- php: >=7.0
Requires (Dev)
- illuminate/support: >=5.4
This package is auto-updated.
Last update: 2024-10-24 04:02:47 UTC
README
This package supports the management view files and assets under separate folders in Laravel projects.
Installation
- Installation with
composer require mikelmi/mks-theme:dev-master
- Add the service provider in
config/app.php
, toproviders
:
Mikelmi\MksTheme\Providers\MksThemeServiceProvider::class,
- Add Facade alias in
config/app.php
, toaliases
:
'Theme' => Mikelmi\MksTheme\Facades\Theme::class,
- Publish config
php artisan vendor:publish --provider="Mikelmi\MksTheme\Providers\MksThemeServiceProvider"
Create/configure theme
- Create new folder in
public/themes/
, for examplepublic/themes/cool-theme
- Set your theme in
config/theme.php
:
'name' => 'cool-theme'
...
- Now you can overwrite any view from
resources/views
within the folderpublic/themes/cool-theme/views
Usage
Theme::set('theme-name'); // switch to 'theme-name'
Theme::get(); // retrieve current theme's name
Theme::all(); // retrieve collection with all themes
Theme::asset('assets/path') // retrieve url to theme asset (e.g.: Theme::asset('assets/css/styles.css'))
Theme::info('key'/** or null */); // retrive theme info (from file /themes/theme-name/theme.php)