shadowfax / zf-themes
Theme system for ZF2
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 0
pkg:composer/shadowfax/zf-themes
Requires
- php: >=5.3.3
- zendframework/zendframework: 2.2.*
This package is not auto-updated.
Last update: 2025-12-20 20:53:19 UTC
README
Zend Framework 2 (ZF2) theme manager
Add the following line to composer.json of your application
"require": {
"shadowfax/zf-themes": "dev-master"
}
In the index.php change
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
with
Themes\Mvc\Application::init(require 'config/application.config.php')->run();
This will load the ThemeManager service.
When creating a new module simply implement Themes\ModuleManager\Feature\ThemeProviderInterface
...
use Themes\ModuleManager\Feature\ThemeProviderInterface;
...
class Module implements ThemeProviderInterface
{
...
public function getDir()
{
return __DIR__;
}
public function getNamespace()
{
return __NAMESPACE__;
}
...
}
The themes should be in a subfolder called themes inside the module directory.
There should be, atleast, a theme called default.
Example tree:
- themes
- default
- my_new_theme
The layout file layout.phtml should be in the root of the theme, all the rest
works just like Zend Framework's view folder.
Assets (CSS, JS, Images,...) can be stored in the assets folder under the theme.
Here is an example entry for the default module.
- default
- assets
- css
- layout.css
- bootstrap.css
- js
- jquery.js
- css
- application
- index
- index.phtml
- index
- layout.phtml
- assets
The module makes a route named assets. The url to assets is
/assets/:modules/*
Where * is the relative path to the actual asset.
Making a port of a Zend Framework 2 application to a theme based applications
should be a breeze as you only have to change the name of view forlder to default,
move it into a folder named themes and move the layout file and you are ready.