Documentation
INI view
Table of Contents ▼
Presentation
The INI view is used to send INI files made from PHP data.
By default, this is a simple stream (as for the JSON view) but, optionally, it is possible to specify a file name. The stream in INI format will then be sent to the browser with instructions to treat it as an attachment and offer the user to save it to disk with the file name in question.
Usage
Here is an example of sending data in INI format:
class ApiController extends \Temma\Web\Controller {
public function getUsers() {
// set the data which will be sent
// in the INI stream
$this['data'] = [
'user1' => [
'name' => 'Alice',
'age' => 28,
],
'user2' => [
'name' => 'Bob',
'age' => 54,
],
];
// set the file name (optional)
$this['filename'] = 'userlist.ini';
// definition of the used view
$this->_view('\Temma\Views\Ini');
}
}
- Lines 5 to 14: The data to be sent in the INI stream are defined by assigning them to the data variable.
- Line 16 : We define the name of the INI file (so that it is treated as an attachment) by assigning it to the filename variable.
- Line 19 : We specify that the view to use for the outgoing data is the INI view (and not the usual Smarty view).
Note: The INI view obviously does not need any templates, since it is the PHP data that is directly serialized.
The received data will look like this:
[user1]
"name"="Alice"
"age"=28
[user2]
"name"="Bob"
"age"=5
Previous: | RSS view |
Next: | iCal view |
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
- External libraries : How to use external function libraries
- 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
- Dependency injection : The backbone of your application developments
- Sessions : Extension of user sessions managed by PHP
- Data sources : Unified data access management
- Model : How to use DAOs to access databases
- Execution flow : How to manage the execution flow, between plugins and the controller
- Plugins : How to use plugins, and create your own plugins to modularize your code
- Attributes : How to filter access to controllers and actions
- Tests : To write automated integration tests.
- Command-line interface : To create executable scripts on the command line, automatically initialized by Temma
- Helpers : Items offered by Temma to help you in various circumstances