• Stars
    star
    361
  • Rank 117,957 (Top 3 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Multi theme support for Laravel application

Multi theme support for Laravel application

Latest Version on Packagist GitHub Tests Action Status Styling Psalm Total Downloads

This Laravel package adds multi-theme support to your application. It also provides a simple authentication scaffolding for a starting point for building a Laravel application. And it also has preset for Bootstrap, Tailwind, Vue, and React. So, I believe it is a good alternative to the laravel/ui & laravel/breeze package.

Features

  • Any number of themes
  • Fallback theme support (WordPress style); It allows creating a child theme to extend any theme
  • Provides authentication scaffolding similar to laravel/ui & laravel/breeze
  • Exports all auth controllers, tests, and other files similar to laravel/breeze
  • Provides frontend presets for Bootstrap, Tailwind, Vue 2, Vue 3 and React

If you don't want to use auth scaffolding of this package, instead you want to use Laravel Fortify, no problem with that. You can use Laravel Themer with Fortify. Laravel Fortify only gives backend implementation authentication, it does not provide views or frontend presets. So, use Fortify for backend auth and Laravel Themer for views and presets.

Tutorial

Here is the video for Laravel Themer Tutorial.

Installation and setup

NOTE:

Laravel Themer v2.x and the above versions support Vite. If you want to use Laravel Mix then try Laravel Themer v1.7.1

You can install this package via composer using:

composer require qirolab/laravel-themer

Publish a configuration file:

php artisan vendor:publish --provider="Qirolab\Theme\ThemeServiceProvider" --tag="config"

Creating a theme

Run the following command in the terminal:

php artisan make:theme

This command will ask you to enter theme name, CSS framework, js framework, and optional auth scaffolding.

Create theme

Useful Theme methods:

// Set active theme
Theme::set('theme-name');

// Get current active theme
Theme::active();

// Get current parent theme
Theme::parent();

// Clear theme. So, no theme will be active
Theme::clear();

// Get theme path
Theme::path($path = 'views');
// output:
// /app-root-path/themes/active-theme/views

Theme::path($path = 'views', $themeName = 'admin');
// output:
// /app-root-path/themes/admin/views

Theme::getViewPaths();
// Output:
// [
//     '/app-root-path/themes/admin/views',
//     '/app-root-path/resources/views'
// ]

Middleware to set a theme

Register ThemeMiddleware in app\Http\Kernel.php:

protected $routeMiddleware = [
    // ...
    'theme' => \Qirolab\Theme\Middleware\ThemeMiddleware::class,
];

Examples for middleware usage:

// Example 1: set theme for a route
Route::get('/dashboard', 'DashboardController@index')
    ->middleware('theme:dashboard-theme');


// Example 2: set theme for a route-group
Route::group(['middleware'=>'theme:admin-theme'], function() {
    // "admin-theme" will be applied to all routes defined here
});


// Example 3: set child and parent theme
Route::get('/dashboard', 'DashboardController@index')
    ->middleware('theme:child-theme,parent-theme');

Asset compilation

To compile the theme assets, first you need to add the following lines in the scripts section of the package.json file.

"scripts": {
    ...

    "dev:theme-name": "vite --config themes/theme-name/vite.config.js",
    "build:theme-name": "vite build --config themes/theme-name/vite.config.js"
}

Now, to compile a particular theme run the following command:

npm run dev:theme-name

# or

npm run build:theme-name

Support us

We invest a lot of resources into video tutorials and creating open-source packages. If you like what I do or if you ever made use of something I built or from my videos, consider supporting us. This will allow us to focus even more time on the tutorials and open-source projects we're working on.

Buy Me A Coffee

Thank you so much for helping us out! 🥰

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

Authentication scaffolding stubs and presets are taken from laravel/ui, laravel/breeze, and laravel-frontend-presets/tailwindcss.

License

The MIT License (MIT). Please see License File for more information.

More Repositories

1

laravel-reactions

Laravel reactions package for implementing reactions (eg: like, dislike, love, emotion, etc) on Eloquent models.
PHP
175
star
2

Laravel-WebSockets-Chat-Example

Example of a real-time chat system built with the Laravel WebSockets package, VueJs, and Laravel-echo.
PHP
103
star
3

laravel-sanctum-example

PHP
72
star
4

learn-vuex-with-basic-ecommerce-example

Watch Vuex state management tutorials here.
PHP
47
star
5

laravel-passport-oAuth2-example

Laravel Passport OAuth2 Tutorial:
PHP
38
star
6

laravel-reverb-chat

Create a Real-Time Chat Applications with Laravel Reverb & Vue.js 3
PHP
29
star
7

laravel-fortify-example

Laravel Authentication Scaffold using Laravel Fortify and Bootstrap.
PHP
24
star
8

laravel-excel-export-import-example

Laravel Excel export, import tutorial with example
PHP
23
star
9

laravel-bannable

Laravel bannable package for blocking and banning Eloquent models.
PHP
18
star
10

laravel-passport-api-authentication-example

How to create API Token Authentication using Laravel Passport, Vue.js, Vuex?
PHP
17
star
11

vuex-tutorial-todos-example

Learn Vuex in 30 minutes | Vuex state management tutorial
Vue
14
star
12

vuex-with-composition-api-example

Vue
7
star
13

laravel-multi-auth-example

PHP
7
star
14

laravel-pdf-tutorial-using-spatie-browsershot

This repository offers a concise tutorial on integrating PDF generation in Laravel using Spatie/Browsershot.
PHP
4
star
15

laravel-fortify-multi-auth-example

PHP
3
star
16

laravel-backup-example

PHP
3
star
17

vue-3-composition-api-tutorial

What's new in Vue 3?
Vue
2
star
18

laravel-reactions-example

PHP
1
star
19

Ctrl-Alt-Cheat-issues

1
star