bahae/laravel-theme-switcher
最新稳定版本:v1.8.0
Composer 安装命令:
composer require bahae/laravel-theme-switcher
包简介
A Laravel package for dynamic theme switching with beautiful color palettes
关键字:
README 文档
README
A powerful and flexible theme management system for Laravel applications. This package provides a complete solution for managing themes, including theme switching, customization, presets, and analytics.
Features
- 🎨 Multiple theme support
- 🎯 Theme preview functionality
- 🛠️ Theme customization interface
- 💾 Theme presets management
- 📊 Theme usage analytics
- 🔄 Theme export/import
- 🌙 Dark/Light mode support
- 📱 Responsive design
- 🎯 Premium themes support
Installation
composer require bahaeddin/laravel-theme-switcher
Publish the configuration and assets:
php artisan vendor:publish --tag=theme-switcher-config php artisan vendor:publish --tag=theme-switcher php artisan vendor:publish --tag=theme-switcher-migrations
Run the migrations:
php artisan migrate
Configuration
The package configuration file (config/themes.php) allows you to customize various aspects of the theme system:
return [ 'default_theme' => 'light', 'themes' => [ 'light' => [ 'name' => 'Light Theme', 'colors' => [ 'primary' => '#007bff', 'secondary' => '#6c757d', // ... other colors ], // ... other settings ], 'dark' => [ 'name' => 'Dark Theme', 'colors' => [ 'primary' => '#0d6efd', 'secondary' => '#adb5bd', // ... other colors ], // ... other settings ], ], ];
Usage
Basic Theme Switching
use Bahae\LaravelThemeSwitcher\Theme; // Switch to a theme Theme::setTheme('dark'); // Get current theme $currentTheme = Theme::getCurrentTheme(); // Get theme settings $settings = Theme::getCurrentSettings();
Theme Preview
Visit /theme-switcher/preview to see the theme preview interface. This allows users to:
- Preview themes before applying
- See live changes
- Compare different themes
- Apply themes with one click
Theme Customization
Visit /theme-switcher/customize to access the theme customizer. Features include:
- Color picker for theme colors
- Typography settings
- Shadow and border controls
- Live preview
- Save custom themes
Theme Presets
Visit /theme-switcher/presets to manage theme presets. Features include:
- Save current theme configuration as a preset
- Apply saved presets
- Manage public and private presets
- Delete custom presets
use Bahae\LaravelThemeSwitcher\ThemePreset; // Create a preset from current theme ThemePreset::createFromCurrent( 'My Preset', 'A custom theme configuration', true, // is public Auth::id() // user ID ); // Get public presets $publicPresets = ThemePreset::getPublicPresets('light'); // Get user presets $userPresets = ThemePreset::getUserPresets('light', Auth::id());
Theme Analytics
Visit /theme-switcher/analytics to view theme usage statistics. Features include:
- Theme switch tracking
- Usage statistics
- Trend analysis
- User preferences
use Bahae\LaravelThemeSwitcher\ThemeAnalytics; // Track a theme switch ThemeAnalytics::trackSwitch('dark'); // Get theme statistics $stats = ThemeAnalytics::getThemeStats('dark'); // Get theme trends $trends = ThemeAnalytics::getThemeTrends('dark');
Export/Import Themes
use Bahae\LaravelThemeSwitcher\Theme; // Export a theme $themeData = Theme::exportTheme('dark'); // Import a theme Theme::importTheme($themeData);
Blade Components
The package includes several Blade components for easy integration:
{{-- Theme Switcher --}} <x-theme-switcher::switcher /> {{-- Theme Preview --}} <x-theme-switcher::preview /> {{-- Theme Customizer --}} <x-theme-switcher::customizer /> {{-- Theme Analytics --}} <x-theme-switcher::analytics />
JavaScript API
The package provides a JavaScript API for theme management:
// Initialize theme switcher const themeSwitcher = new ThemeSwitcher(); themeSwitcher.init(); // Switch theme themeSwitcher.switchTheme('dark'); // Get current theme const currentTheme = themeSwitcher.getCurrentTheme(); // Save preset themeSwitcher.savePreset({ name: 'My Preset', description: 'A custom theme', isPublic: true });
Events
The package fires several events that you can listen to:
// Theme switched ThemeSwitched::class // Theme customized ThemeCustomized::class // Preset created PresetCreated::class // Preset applied PresetApplied::class
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
License
This package is open-sourced software licensed under the MIT license.
Support
For support, please open an issue on GitHub or contact the maintainers.
Changelog
v1.8.0
- Added theme presets functionality
- Added theme analytics
- Enhanced theme customization
- Improved UI/UX
v1.7.0
- Added theme preview
- Added theme customization
- Enhanced theme switching
v1.6.0
- Added premium themes
- Enhanced theme system
- Improved performance
bahae/laravel-theme-switcher 适用场景与选型建议
bahae/laravel-theme-switcher 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bahae/laravel-theme-switcher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bahae/laravel-theme-switcher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bahae/laravel-theme-switcher 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Alfabank REST API integration
High-performance, opinionated PHP 8 web framework with O(1) routing, parallel async MySQL, type-safe asset bridge, and React-island frontend
Laravel package for Accurate Online API integration.
The skeleton application for the Geoffrey agent framework.
Shared RCX Laravel DataTables UI and configuration helpers.
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-14