Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Multi theme support for Laravel application

License

NotificationsYou must be signed in to change notification settings

qirolab/laravel-themer

Repository files navigation

Latest Version on PackagistGitHub Tests Action StatusStylingPsalmTotal 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 forBootstrap,Tailwind,Vue, andReact. So, I believe it is a good alternative to thelaravel/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 tolaravel/ui &laravel/breeze
  • Exports all auth controllers, tests, and other files similar tolaravel/breeze
  • Provides frontend presets forBootstrap,Tailwind,Vue 2,Vue 3 andReact

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

Tutorial

Here is the video forLaravel Themer Tutorial.

Installation and setup

NOTE:

Laravel Themer v2.x and the above versions supportVite.If you want to useLaravel Mix then tryLaravel 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 themeTheme::set('theme-name');// Get current active themeTheme::active();// Get current parent themeTheme::parent();// Clear theme. So, no theme will be activeTheme::clear();// Get theme pathTheme::path($path ='views');// output:// /app-root-path/themes/active-theme/viewsTheme::path($path ='views',$themeName ='admin');// output:// /app-root-path/themes/admin/viewsTheme::getViewPaths();// Output:// [//     '/app-root-path/themes/admin/views',//     '/app-root-path/resources/views'// ]

Middleware to set a theme

RegisterThemeMiddleware inapp\Http\Kernel.php:

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

Examples for middleware usage:

// Example 1: set theme for a routeRoute::get('/dashboard','DashboardController@index')    ->middleware('theme:dashboard-theme');// Example 2: set theme for a route-groupRoute::group(['middleware'=>'theme:admin-theme'],function() {// "admin-theme" will be applied to all routes defined here});// Example 3: set child and parent themeRoute::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 thescripts section of thepackage.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# ornpm run build:theme-name

Testing

composertest

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! 🥰

Spec Coder

Changelog

Please seeCHANGELOG for more information on what has changed recently.

Contributing

Please seeCONTRIBUTING for details.

Security Vulnerabilities

Please reviewour security policy on how to report security vulnerabilities.

Credits

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

License

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


[8]ページ先頭

©2009-2025 Movatter.jp