Merge pull request #4 from Orange-Management/develop

Update and restructure
This commit is contained in:
Dennis Eichhorn 2016-08-09 23:54:09 +02:00 committed by GitHub
commit 20255a5862
12 changed files with 99 additions and 56 deletions

View File

@ -13,13 +13,11 @@
## Basics
* [Php](basics/routing.md)
* [Php](basics/dispatching.md)
* [Php](basics/views.md)
### Http
* [Requests](basics/http/requests.md)
* [Responses](basics/htttp/responses.md)
* [Routing](basics/routing.md)
* [Dispatching](basics/dispatching.md)
* [Views](basics/views.md)
* [Requests](basics/requests.md)
* [Responses](basics/responses.md)
## Security
* [Security Guidelines](security/security_guidelines.md)
@ -27,6 +25,8 @@
## DataStorage
* [Cache](datastorage/cache.md)
* [Session](datastorage/session.md)
* [Cookie](datastorage/cookie.md)
* [LocalStorage](datastorage/localstorage.md)
### Database
* [DataMapper](datastorage/database/datamapper.md)
@ -58,6 +58,4 @@
* [Styles and Layout](frontend/styles_and_layout.md)
## Components
* [Caching, Sessions, Local Storage & Cookies](components/caching,_sessions,_local_storage_&_cookies.md)
* [Modules](components/modules.md)
* [Modules](components/datamapper.md)

13
basics/requests.md Normal file
View File

@ -0,0 +1,13 @@
# Requests
Requests can be either incoming requests such as http requests on the server side or outgoing requests such as ajax requests on the client side. At the same time it's also possible to generate outgoing requests on the server side for microservices as well as REST requests to third party APIs.
## Http Requests
## Rest Requests
## Socket Requests
## Websocket Requests
## JavaScript Requests

9
basics/responses.md Normal file
View File

@ -0,0 +1,9 @@
# Responses
Responses can be either outgoing responses such as http or socket responses on the server side or responses generated on the client side for socket/websocket requests. Responses usually get generated based on a request.
## Http Response
## Socket Response
## Websocket Response

View File

@ -0,0 +1,29 @@
# Views
Views contain the raw information of a result which then depending on the template will be rendered. While it is possible to use the generic `View` class which provides the `addData()` `setData()` and `getData()` methods it is recommended to generate more specialized views for better variable handling as well as providing view logic. The template itself should not contain view logic and only representation logic. In some cases however it is required to modify/transform data which should be handled in the view.
## Implementation
A view must implement `\Serializable` and `\JsonSerializable`.
In case the response header is set to JSON the view will automatically get parsed as JSON object, either by using a the JSON template or by encoding the view. For the JSON serialization the `jsonSerialize()` function will be used in all other cases the `serialize()` function will be used.
## Localization
The base view class contains the request as well as the response objects hence it also contains the request/response localization. One of the most important methods is the `getText()` method. This private method allows for module and theme specific translations of defined language elements.
In the template you can simply use `$this->getText({TEXT_ID})` for localized text. All other localization elements can be accessed in a similar way e.g. `$this->l11n->getTemperature()`
## Templates
Templates can be set with the `setTemplate()` method. It is important to note that templates MUST have the file ending `.tpl.php`. Other file endings are not supported.
```
$view->setTemplate('/Modules/Test/Theme/Backend/template_file');
```
Note that the path definition doesn't include the file ending.
## Data Binding
In the generic view it's possible to bind data by using the `setData()` method and this data can be accessed by using the `getData()` method.

View File

@ -1,46 +0,0 @@
# Caching, Sessions, Local Storage & Cookies
## Caching
For caching the `CacheManager` provides access to the caching systems in place. Out of the box the CacheManager supports and automatically initializes either Redis or Memcached depending on the client configuration. The caching is not mandatory and therfor shouldn't be missuesed as in-memory database. It is not necessary to check if Redis or Memcached are available the CacheManager automatically handles the caching based on their existence.
### HTTP Cache
By default only stylesheets, javascript and layout images as well as module images are cached. Everything else is considered volatile and not cached. If a response specific response should be cached feel free to use the response header:
Example usage for 30 days caching:
```
$resposne->setHeader('Cache-Control', 'Cache-Control: max-age=2592000');
```
In order to trigger a re-cache of stylesheets or javascript files make sure to update the version in the `Controller.php` file. This way version updates will result in a new virtual file uri and result in a re-cache.
Example usage:
```
$head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Media/Controller.js?v=' . self::MODULE_VERSION);
```
## Sessions
Sessions are handled via the `SessionManager`. Sessions can be set and manipulated from the web application as well as the socket or console application.
### HTTP
The Http session will be saved automatically, there is no need to access the super global `$_SESSION`. Make sure to only modify session data using the SessionManager
### Socket & Console
The session will be stored and assoziated with the logged in user in memory. A disconnect or quit is considered as a logout and therefor results in the destruction of the session object of this user and will be empty for the next login.
## Local Storage
## Cookies
### PHP
Only use cookies when absolutely necessary. Most of the time session data or local storage is the prefered choice. The `CookieJar` class provides you with all the necessary functionality similar to the `SessionManager`. The super global `$_COOKIE` is also overwritten and shouldn't be used anywhere.
### JavaScript

View File

@ -0,0 +1,21 @@
## Cache
For caching the `CacheManager` provides access to the caching systems in place. Out of the box the CacheManager supports and automatically initializes either Redis or Memcached depending on the client configuration. The caching is not mandatory and therfor shouldn't be missuesed as in-memory database. It is not necessary to check if Redis or Memcached are available the CacheManager automatically handles the caching based on their existence.
### HTTP Cache
By default only stylesheets, javascript and layout images as well as module images are cached. Everything else is considered volatile and not cached. If a response specific response should be cached feel free to use the response header:
Example usage for 30 days caching:
```
$resposne->setHeader('Cache-Control', 'Cache-Control: max-age=2592000');
```
In order to trigger a re-cache of stylesheets or javascript files make sure to update the version in the `Controller.php` file. This way version updates will result in a new virtual file uri and result in a re-cache.
Example usage:
```
$head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Media/Controller.js?v=' . self::MODULE_VERSION);
```

7
datastorage/cookie.md Normal file
View File

@ -0,0 +1,7 @@
# Cookies
## PHP
Only use cookies when absolutely necessary. Most of the time session data or local storage is the prefered choice. The `CookieJar` class provides you with all the necessary functionality similar to the `SessionManager`. The super global `$_COOKIE` is also overwritten and shouldn't be used anywhere.
## JavaScript

View File

@ -0,0 +1 @@
# LocalStorage

View File

@ -0,0 +1,11 @@
# Sessions
Sessions are handled via the `SessionManager`. Sessions can be set and manipulated from the web application as well as the socket or console application.
## HTTP
The Http session will be saved automatically, there is no need to access the super global `$_SESSION`. Make sure to only modify session data using the SessionManager
## Socket & Console
The session will be stored and assoziated with the logged in user in memory. A disconnect or quit is considered as a logout and therefor results in the destruction of the session object of this user and will be empty for the next login.

View File

@ -53,7 +53,7 @@ The currency code of the localization object is the 3 character ISO4217 code. Th
The currency symbol can be placed either in front or at the end of a value. The `Money` class provides a function called `getCurrency()` which returns a localized representation by specifying the thousands and decimal separator as well as the currency symbol and its position.
```
$money->getcurrency(2, ',', '.', '$', 0);
$money->getCurrency(2, ',', '.', '$', 0);
```
### DateTime