Download the PHP package akbardwi/laratheme without Composer
On this page you can find all versions of the php package akbardwi/laratheme. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download akbardwi/laratheme
More information about akbardwi/laratheme
Files in akbardwi/laratheme
Package laratheme
Short Description Theme and asset management for laravel
License CC-BY-3.0
Homepage https://github.com/akbardwi/laratheme
Informations about the package laratheme
Laravel-Laratheme
Laratheme is a Laravel theme and asset management package. You can easily integrate this package with any Laravel based project.
Features
- Custom theme path
- Override theme
- Parent theme support
- Unlimited Parent view finding
- Asset Finding
- Theme translator support
- Multiple theme config extension
- Multiple theme changelog extension
- Artisan console commands
- Theme enable only Specific route via middleware
- Almost everything customizable
- Also Laravel 5.5 to Laravel 10 Supported
Installation
Laratheme is a Laravel package so you can install it via Composer. Run this command in your terminal from your project directory:
Wait for a while, Composer will automatically install Laratheme in your project.
Configuration
Below Laravel 5.5 you have to call this package service in config/app.php
config file. To do that, add this line in app.php
in providers
array:
Below Laravel 5.5 version to use facade you have to add this line in app.php
to the aliases
array:
Now run this command in your terminal to publish this package resources:
Artisan Command
Run this command in your terminal from your project directory.
Create a theme directory:
List of all themes:
Example folder structure:
You can change theme.json
and changelog.yml
name from config/theme.php
json
, yml
, yaml
, php
, ini
, xml
extension supported.
For example:
Then run theme:create
command which describe above.
Now Please see the API List Doc.
View Finding Flow:
Suppose you want find welcome.blade.php
API List
set
For switching current theme you can use set
method.
get
For getting current theme details you can use get
method:
You can also get particular theme details:
current
Retrieve current theme's name:
all
Retrieve all theme information:
has
For getting whether the theme exists or not:
getThemeInfo
For info about the specified theme:
Also fallback support:
assets
For binding theme assets you can use the assets
method:
It's generated at BASE_URL/theme_roots/your_active_theme_name/assets/your_asset_path
If your_asset_path
does not exist then it's find to active theme immediate parent assets folder. Look like BASE_URL/theme_roots/your_active_theme_parent_name/assets/your_asset_path
When using helper you can also get assets path:
If you want to bind specific theme assets:
Suppose you want to bind app.css
in your blade. Then below code can be applicable:
Specific theme assets:
lang
The lang
method translates the given language line using your current theme localization files:
also support
If you want to bind specific theme assets:
How to use in Route
This will firstly check if there is a welcome.blade.php in current theme directory. If none is found then it checks parent theme, and finally falls back to default Laravel views location.
If you want to specific theme view:
Set theme using route middleware
A helper middleware is included out of the box if you want to define a theme per route. To use it:
First register it in app\Http\Kernel.php:
Now you can apply the middleware to a route or route-group. Eg:
Set theme using web middleware
A helper middleware is included out of the box if you want to define a theme per route. To use it:
First register it in app\Http\Kernel.php:
Theme set from config/theme.php
.
Then in your controller you can call your view as you would normally do:
Dependency Injection
You can also inject theme instance using ThemeContract, eg:
Troubleshooting
Clear config after runing vendor publish
(see Config section) to save issues related to config caching by running:
php artisan config:cache
php artisan config:clear
Credits
- Shipu Ahamed
- Akbar Dwi Syahputra
- All Contributors