monkblog/theme-manager
最新稳定版本:v1.1.2
Composer 安装命令:
composer require monkblog/theme-manager
包简介
A simple theme manager
README 文档
README
A simple theme manager that can be used with Laravel 5.
Requirements
- Use with Laravel requires version 5 or above.
- PHP 5.5.9 or greater
Installation
Require this package with Composer
composer require monkblog/theme-manager 1.1.*
Show me the examples already!!
Documentation
- Requiring Theme Meta Data Field(s)
- Error Handling
- Folder Structure
- Bootstrapping Theme Classes
- Using with Laravel
- License
Requiring Theme Meta Data Field(s)
This package requires that a theme.yml/theme.yaml file have at least a name field defined.
As of version 1.1 you can define a list of required fields that need to be defined in each theme.yml file.
This package will handle and separate the invalid themes from the valid ones.
Go to config/theme-manager.php and change required_fields to the array of required field(s) to be enforced.
(see Publish Config section if config is not in your config folder).
Injecting Required Field(s) into Starter Class
If you're not using the Laravel Service Provider, you can pass an array to the \ThemeManager\Starter start() method:
$basePath = null; $requiredFields = [ 'display_name', 'version', 'license', ]; $starter = ( new \ThemeManager\Starter )->start( $basePath, $requiredFields ); $themeManager = new \ThemeManager\ThemeManager( $starter );
You may also use the helper function as a shortcut:
$themeManager = theme_manager( null, [ 'display_name', 'version', 'license', ] );
Error Handling
As of version 1.1 there's a boolean $exceptionOnInvalid which by default is false. To have the package throw exceptions
for invalid themes change exception_on_invalid in config/theme-manager.php to be true or pass true as the $exceptionOnInvalid
argument on the start method of \ThemeManager\Starter class.
Folder Structure
This package assumes that you have a themes folder at the root of your project containing all your theme folders.
The 'base path' can be overwritten via config/theme-manager.php or the start( __DIR__ . '/folder/' ) method on the \ThemeManager\Starter class
e.g.
# themes/my-theme/theme.yml name: my-theme
- app/
- public/
- themes/
- my-theme/
- theme.yml
- my-theme-with-autoload/
- composer.json
- helpers.php
- src/
- MyThemeNamespace/
- MyClass.php
- MyThemeServiceProvider.php
- MyThemeNamespace/
- theme.yml
- vendor/
- my-other-theme/
- theme.yml
- my-theme/
- vendor/
Bootstrapping Theme Classes
Bootstrapping theme Service Provider(s) or other important classes before the application runs:
For Laravel users: this code snippet is probably best placed at the bottom of bootstrap/autoload.php
( new \ThemeManager\Starter )->bootstrapAutoload();
OR
theme_manager_starter()->bootstrapAutoload();
You can also optionally pass in a path to your themes folder if it's different than the default:
theme_manager_starter()->bootstrapAutoload( '/path/to/theme-folder' );
Using with Laravel
Once Composer has installed or updated your packages, you need to register ThemeManager with Laravel. Go into your config/app.php, find the providers key and add:
'ThemeManager\ServiceProvider',
You can add the ThemeManager Facade, to have easier access to the ThemeManager globally:
'ThemeManager' => 'ThemeManager\Facade\ThemeManager',
Usages:
ThemeManager::all(); ThemeManager::getAllThemeNames(); ThemeManager::themeExists( 'theme-name' ); $theme = ThemeManager::getTheme( 'theme-name' ); $themeName = $theme->getName();
Publish Config
Run:
php artisan vendor:publish --tag=theme
Override the base themes path:
(See Publish Config section if theme-manager.php isn't present)
Go to config/theme-manager.php and change the base_path to the folder you want to use.
<?php return [ 'base_path' => __DIR__ . '/../path/to/themes-folder', //Other config stuff ... ];
Adding more Themes folder to Manager
If you have a secondary themes folder you can add all of the themes to the ThemeManager by using:
ThemeManager::addThemeLocation( base_path( '/path/to/alternative/themes-folder' ) );
License
This package is open-sourced software licensed under the MIT license.
monkblog/theme-manager 适用场景与选型建议
monkblog/theme-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 97 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「themes」 「theme」 「manager」 「Simple」 「laravel」 「monk」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 monkblog/theme-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 monkblog/theme-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 monkblog/theme-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Themes
WordPress mu-plugin to register the theme directory for the default WordPress themes.
This is twig version of Flow Theme for OXID eShop.
Test theme for Altis DXP, based on Automattic/_s starter theme.
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
This is a Smarty version of Admin Theme for OXID eShop.
统计信息
- 总下载量: 97
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-14