atukai / theme-middleware
Themes support for Zend Expressive
Requires
- php: ^7.0
- psr/container: ^1.0
- psr/http-message: ^1.0
- zendframework/zend-expressive-template: ^1.0.1
- zendframework/zend-stdlib: ^2.7 || ^3.0
README
Support themes middleware that allows to switch between themes. It is generally designed for Zend Expressive.
Installation
composer require atukai/theme-middleware
Usage
Zend Expressive:
Include config from ConfigProvider.php. Recommend to use [Expressive Configuration Manager] (https://github.com/mtymek/expressive-config-manager)
$configManager = new ConfigManager([ ..., \At\Theme\ConfigProvider::class, ]);
Create themes folder.
./themes
Configure your settings.
'themes' => [ 'theme_paths' => [ __DIR__ . '/../themes/' ], ];
Other frameworks:
You should implement Zend\Expressive\Template\TemplateRendererInterface
and
put it under TemplateRendererInterface::class
key into your container
Resolvers
It uses resolvers to detect theme name that should be currently used for rendering.
By default the At\Theme\Resolver\ConfigurationResolver
is used to get theme specified in config.
You can add one or more resolvers with priority.
'themes' => [ 'paths' => [ __DIR__ . '/../themes/' ], 'default_theme' => 'default', 'resolvers' => [ \At\Theme\Resolver\HttpRequestResolver::class => 20, ], ];
Assets
'themes' => [ 'paths' => [ __DIR__ . '/../themes/' ], 'default_theme' => 'default', 'resolvers' => [ \At\Theme\Resolver\HttpRequestResolver::class => 20, ], 'assets' => [ 'paths' => [__DIR__ . '/../themes/default/assets'], 'cache_dir' => __DIR__ . '/../public' ] ];