Multi theme support for Laravel application

Overview

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

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

Create theme

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

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:

middleware('theme:child-theme,parent-theme'); ">
// 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, you need to add the theme's webpack.mix.js in the root webpack.mix.js.

// add this in the root `webpack.mix.js`
require(`${__dirname}/themes/theme-name/webpack.mix.js`);

Now you can run the npm install and npm run dev command to compile theme assets.

If you add multiple webpack.mix.js of different themes in the root webpack.mix.js, then webpack may not compile these correctly. So, you should modify the root webpack.mix.js with the following code:

let theme = process.env.npm_config_theme;

if(theme) {
   require(`${__dirname}/themes/${theme}/webpack.mix.js`);
} else {
    // default theme to compile if theme is not specified
  require(`${__dirname}/themes/theme-name/webpack.mix.js`);
}

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

npm run dev --theme=theme-name

# or

npm run watch --theme=theme-name

# or

npm run production --theme=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.

Comments
  • Can't use multiple themes in same time with Vite

    Can't use multiple themes in same time with Vite

    Hello,

    Thanks a lot for this greate package, I use it with every project even If I need single theme! really in love with it 💌

    The issue : In version 2 with the vite thing, when we do npm run build:theme1 and then npm run build:theme2 There is only one build folder in public and one manifesto file, which breaks everything. Not like the v1 when using mix, there were multiple build folders for each theme in public/theme1/css and public/theme2/css etc ..

    Any idea how this will be resolved ? Thanks.

    opened by onemoreahmad 2
  • Laravel Cache Busting not working anymore.

    Laravel Cache Busting not working anymore.

    Hi, Laravel Cache Busting isn't working anymore. Our project before integrating the Qirolab Theming Plugin, instead of the asset function we used the mix function and then added this in our root webpack.mix.js file:

    if (mix.inProduction()) {
        mix.version();
    }
    

    Our css and js files used to have a hash at the end of the file name, now using the Plugin, they don't the hash anymore. Does this Plugin support Laravel Cache Busting?

    opened by RyanSacks 1
  • The Middleware in my opinion doesn't work properly.

    The Middleware in my opinion doesn't work properly.

    I have a page and a route "a" that belongs to theme1. I added the Middleware to the Kernel and added a Middleware on this route in web.php and set it to "theme:theme1". Right now the active theme is set to theme2 in config/theme.php but when I go to /a I still see the page, it should not allow you to view the page, that's the whole point of a Middleware. Did I do something wrong?

    opened by RyanSacks 1
  • mix-manifest.json file not appearing after compiling theme assets.

    mix-manifest.json file not appearing after compiling theme assets.

    Hi, I created a new theme add selected skip for everything because I have an existing application that has Bootstrap, Blade and Authentication. So I'm creating folders manually based on the Advertised Video Tutorial. My only issue is that when I run npm run dev --theme=theme-name it compiles my assets but doesn't produce a mix-manifest.json inside my theme folder. How can I solve this issue?

    opened by RyanSacks 1
  • after all setup have an error

    after all setup have an error

    Fatal error: Uncaught ReflectionException: Class theme.finder does not exist in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:833 Stack trace: #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(833): ReflectionClass->__construct('theme.finder') #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(714): Illuminate\Container\Container->build('theme.finder') #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->resolve('theme.finder', Array, true) #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(652): Illuminate\Foundation\Application->resolve('theme.finder', Array) #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\Container\Container->make('theme.finder', Array) #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(119): Illuminate\Foundation\Application->make(' in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 835

    opened by maxlen 1
Releases(2.0.2)
Owner
QiroLab
We ❤ Open Source.
QiroLab
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant

The unobtrusive Laravel package that makes your app multi tenant. Serving multiple websites, each with one or more hostnames from the same codebase. B

Tenancy 2.4k Jan 3, 2023
Bring multi themes support to your Laravel application with a full-featured Themes Manager

Introduction hexadog/laravel-themes-manager is a Laravel package which was created to let you developing multi-themes Laravel application. Installatio

hexadog 86 Dec 15, 2022
Taskpm - Run multi tasks by PHP multi process

php-pkg-template Run multi tasks by PHP multi process Install composer composer require phppkg/taskpm Usage github: use the template for quick create

PHPPkg 2 Dec 20, 2021
Textpattern-default-theme - Textpattern CMS default theme.

Textpattern CMS default theme This project is the source for the default theme that ships as standard with Textpattern CMS. It is intended as a starti

Textpattern CMS 61 Nov 21, 2022
Textpattern-jquery-ui-theme - The jQuery UI theme used within the Textpattern CMS admin-side.

Textpattern jQuery UI theme The jQuery UI theme used within the Textpattern CMS admin-side. Supported web browsers Chrome, Edge, Firefox, Safari and O

Textpattern CMS 12 Jan 10, 2022
A Laravel extension for using a laravel application on a multi domain setting

Laravel Multi Domain An extension for using Laravel in a multi domain setting Description This package allows a single Laravel installation to work wi

null 658 Jan 6, 2023
A Multi User Chat Application With Laravel and Livewire

A Multi User Chat Application With Laravel and Livewire. where you can chat with multiple frinds at the same time. i build this with php Laravel and Livewire.

Tauseed 15 Oct 22, 2022
Easily integrate single-database multi tenant features into your Laravel application

Laravel Tenant Aware Easily integrate single-database multi tenant features into your Laravel application. Installation You can install the package vi

H-FARM Innovation 9 Dec 21, 2022
Automatic multi-tenancy for Laravel. No code changes needed.

Tenancy for Laravel — stancl/tenancy Automatic multi-tenancy for your Laravel app. You won't have to change a thing in your application's code. ✔️ No

Samuel Štancl 2.7k Jan 3, 2023
Tiny hands is a Laravel multi-tenant boilerplate with SPA and i18n.

About Tiny Hands Tiny hands is a Laravel multi-tenant boilerplate with SPA and i18n using the following technology stack: Backend Laravel 8.0 API with

Bertrand Kintanar 12 Jun 23, 2022
🧙‍♀️ Arcanist takes the pain out of building multi-step form wizards in Laravel.

Installation Arcanist requires PHP 8 and Laravel 8. composer require laravel-arcanist/arcanist Documentation You can find the full documentation here

Arcanist 378 Jan 3, 2023
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups.

Tenancy for Laravel Enabling awesome Software as a Service with the Laravel framework. This is the successor of hyn/multi-tenant. Feel free to show su

Tenancy 1.1k Dec 30, 2022
Laravel-Mix helper for projects with complex & multi assets.

Laravel-Mix helper for projects with complex & multi assets. ?? Getting started Since mix introduced in laravel 5.4 it is recommended to use this pack

Fandogh 27 Oct 4, 2022
Rinvex Tenantable is a contextually intelligent polymorphic Laravel package, for single db multi-tenancy.

Rinvex Tenants is a contextually intelligent polymorphic Laravel package, for single db multi-tenancy. You can completely isolate tenants data with ease using the same database, with full power and control over what data to be centrally shared, and what to be tenant related and therefore isolated from others.

Rinvex 80 Oct 21, 2022
An example of multi-domain/subdomain app in Laravel.

?? UPDATE A better example with online demo: https://github.com/laravel-101/multi-domain-laravel-app Multi-Domain Laravel App An example of multi-doma

DigitalWheat 204 Dec 27, 2022
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously

Tenancy 2.4k Jan 3, 2023
Multi layout react laravel

multi-layout-react-laravel multi layout react-laravel is a repository for creating 1 integrated system, this repository uses react(laravel ui) version

null 2 Feb 13, 2022
A dynamic Laravel Livewire component for multi steps form

Livewire component that provides you with a wizard that supports multiple steps form while maintaining state.

Vildan Bina 233 Jan 4, 2023
A Laravel package that allows you to use multiple ".env" files in a precedent manner. Use ".env" files per domain (multi-tentant)!

Laravel Multi ENVs Use multiple .envs files and have a chain of precedence for the environment variables in these different .envs files. Use the .env

Allyson Silva 48 Dec 29, 2022