Download the PHP package responsive-sk/slim4-themes without Composer
On this page you can find all versions of the php package responsive-sk/slim4-themes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download responsive-sk/slim4-themes
More information about responsive-sk/slim4-themes
Files in responsive-sk/slim4-themes
Package slim4-themes
Short Description Theme system for Slim 4 applications with DI support
License MIT
Informations about the package slim4-themes
Slim4 Themes
Theme handling for Slim 4 applications.
Version 2.0 Changes
Version 2.0 introduces a new approach to theme handling using Dependency Injection (DI) instead of middleware. This provides several advantages:
- Separation of concerns: Theme handling is a cross-cutting concern that should be handled at the container level, not in the HTTP request pipeline.
- Performance: DI-based theme handling is more efficient because it doesn't require processing the request for every request.
- Flexibility: DI-based theme handling allows you to use the theme in any part of your application, not just in the HTTP request pipeline.
- Testability: DI-based theme handling is easier to test because you can mock the theme provider.
Installation
Usage
1. Register the services
Using PHP-DI
Using Symfony Container
2. Add the middleware
3. Use the theme in your application
Components
ThemeResolver
The ThemeResolver class is responsible for resolving the theme based on the request, cookies, or default theme.
ThemeProvider
The ThemeProvider class is responsible for providing the theme from the container.
RequestAwareMiddleware
The RequestAwareMiddleware class is responsible for making the request available to the ThemeProvider.
ThemeServiceProvider
The ThemeServiceProvider class is responsible for registering theme services in the container.
Migrating from Version 1.x
If you're migrating from version 1.x, here are the main changes:
-
Replace
ThemeMiddlewarewithRequestAwareMiddleware: -
Get the theme from the container instead of the request attribute:
- Register the new services in your container:
License
MIT
All versions of slim4-themes with dependencies
slim/slim Version ^4.0
responsive-sk/slim4-root Version ^1.0
psr/http-message Version ^1.0 || ^2.0
psr/http-server-middleware Version ^1.0 || ^2.0
psr/log Version ^1.0 || ^2.0 || ^3.0
psr/container Version ^1.0 || ^2.0
twig/twig Version ^3.0