https://github.com/thinhbuzz/laravel-theme
Theme Management for Laravel 5.*
https://github.com/thinhbuzz/laravel-theme
Last synced: 11 months ago
JSON representation
Theme Management for Laravel 5.*
- Host: GitHub
- URL: https://github.com/thinhbuzz/laravel-theme
- Owner: thinhbuzz
- License: mit
- Created: 2015-08-07T10:59:16.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-01-04T06:54:28.000Z (over 10 years ago)
- Last Synced: 2025-07-02T06:55:45.429Z (11 months ago)
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 8
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Theme Management for Laravel 5.*
> Detect device use package [serbanghita/Mobile-Detect](https://github.com/serbanghita/Mobile-Detect).
> If you want to be simple, use a version 1.
> Note: v2.* switch language to vietnamese
## Contents
1. Introduction
2. Installation
3. Configuration
4. Structure
5. Usage
## Introduction
This is package support the management view files and assets under separate folders. Compatible with Laravel 5.*
## Installation
The first run command:
```
composer require buzz/laravel-theme 2.*
```
and then open `config/app.php` add `LaravelThemeServiceProvider` to array `providers`
```
'providers' => [
//.....
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider,
//.....
'Buzz\LaravelTheme\LaravelThemeServiceProvider',
],
```
Add `Theme` alias (when set `auto_alias => false` in theme config):
```
'aliases' => [
//.....
'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View',
//.....
'Theme' => 'Buzz\LaravelTheme\ThemeFacade',
],
```
## Configuration
Publish config file `config/theme.php` with command:
~~~
php artisan vendor:publish --provider="Buzz\LaravelTheme\LaravelThemeServiceProvider"
~~~
## Usage
### Structure
##### Assets
```
├── public/
└── themes/
├── theme_name/
| ├── js/
| ├── css/
|
└── another_theme_name/
```
##### Views
```
├── resources/
└── themes/
├── theme_name/
| ├── index.blade.php
| ├── footer.blade.php
|
└── another_theme_name/
```
### Render view
package does not change the way you render view, you still use the `View::make` or `view()` as default of laravel, read more on [views document](http://laravel.com/docs/5.1/views). If the render view and the view does not exist in the `resources/themes/theme-name`, it will render view in `resources/views`.
### Theme assets
Use ``themeAsset()`` instead of ``asset()`` when link to assets in theme, example:
```php
//render
```
### Change current theme
You can change the theme in the following ways:
```php
app('theme')->set($themeName)
```
Or use function helper
```php
setTheme($themeName);//function helper
```
or use Facade
```php
Theme::set($themeName);//use facade
```
### Support methods
```php
Theme::client();//return object of MobileDetect
Theme::pathTheme($name = null);//return path to current theme or name input
Theme::currentTheme();//return name of current theme
Theme::reset();//reset default theme
Theme::set();//set theme
Theme::allTheme($except = [], $config = true);//get list theme in folder themes
themeAsset($name = false);//link to asset current theme or by theme name
setTheme($name);// change theme by theme name
```
### Support other config provider
By default package use provider ``config`` of laravel, you can change to provider you want by edit config ``'config_provider' => 'provider_name'``
> P/s: excuse me my English.