Documentation
Plugins
- Migration : How to upgrade from Temma 1.x to version 2
- Installation : Download Temma and install it to start your web project
- Configuration : All the configuration directives of the etc/temma.json file and the optional environment variables
- Routing : Temma's default routing system, and advanced routing
- Log : Use of the log system, management by criticality levels
- Controllers : Essential parts of your web application
- Views : Smarty templates or JSON/CSV/RSS/iCal/INI exports
- Dependencies injection : The backbone of your application developments
- Sessions : Extension of user sessions managed by PHP
- Cache : So as not to redo the same calculations several times
- Model : How to use DAOs to access databases
- Plugins : How to create your own plugins, and a list of plugins offered by Temma
- Execution flow : How to manage the execution flow, between plugins and the controller
- Helpers : Items offered by Temma to help you in various circumstances
Presentation
It is possible to request the execution of plugins, before and/or after the execution of the application controllers. Technically, plugins are controllers with special methods, which can modify the request before passing it on to the next plugin or to the designated controller. You can chain plugins before the controller, and other plugins after.
The source files for plugins are stored in the controllers directory of the application.
The same object can have both plugin and controller roles.
Configuration
The configuration of pre-plugins and post-plugins is done using the temma.json file (see the configuration documentation). It is possible to configure global plugins, which will be executed for all requests:
{
"plugins": {
// list of pre-plugins */
"_pre": [
"AuthenticationPlugin",
"CmsController"
],
// list of post-plugins
"_post": [
"CleanSessionPlugin"
]
}
}
Plugins are executed following the order in which they are declared.
It is possible to configure plugins that will only run for certain controllers:
{
"plugins": {
// plugins systematically executed for all controllers
"_pre": ["AuthenticationPlugin", "CmsController"],
"_post": ["CleanSessionPlugin"],
// plugins called only for the homepage controller
"Homepage": {
// plugins executed before the controller
"_pre": ["SomePlugin", "AnotherPlugin"],
// plugins executed after the controller
"_post": ["LastPlugin"]
},
// plugins called only for the display controller
"Display": {
"_post": ["CheckOutputPlugin"]
}
}
}
It is even possible to define plugins that will only be called for certain actions:
{
"plugins": {
// plugins called only for the homepage controller
"Homepage": {
// plugins executed before the controller
"_pre": ["SomePlugin", "AnotherPlugin"],
// plugins executed after the controller
"_post": ["LastPlugin"],
// plugins for the show action
"show": {
// plugins executed before the action
"_pre": ["SpecialPlugin"],
// plugins executed after the action
"_post": ["FooPlugin"]
},
// plugins for the remove action
"remove": {
// plugins executed before the action
"_pre": ["BarPlugin"]
}
}
}
}
Previous: | Model |
Next: | Custom plugins |
Table of Contents
- Migration : How to upgrade from Temma 1.x to version 2
- Installation : Download Temma and install it to start your web project
- Configuration : All the configuration directives of the etc/temma.json file and the optional environment variables
- Routing : Temma's default routing system, and advanced routing
- Log : Use of the log system, management by criticality levels
- Controllers : Essential parts of your web application
- Views : Smarty templates or JSON/CSV/RSS/iCal/INI exports
- Dependencies injection : The backbone of your application developments
- Sessions : Extension of user sessions managed by PHP
- Cache : So as not to redo the same calculations several times
- Model : How to use DAOs to access databases
- Plugins : How to create your own plugins, and a list of plugins offered by Temma
- Execution flow : How to manage the execution flow, between plugins and the controller
- Helpers : Items offered by Temma to help you in various circumstances