From c2be3cea12bb75f1c28b74b2ec1f8f2c3939273b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 9 Aug 2016 18:19:10 +0200 Subject: [PATCH 1/3] Fix function name --- services/localization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/localization.md b/services/localization.md index 0eca434..8b0c5c4 100644 --- a/services/localization.md +++ b/services/localization.md @@ -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 From 4c1af984b4161eba6b4f476cf378008dbc20fdda Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 9 Aug 2016 18:30:05 +0200 Subject: [PATCH 2/3] Fix index names --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 0944248..8c525c4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -13,9 +13,9 @@ ## Basics -* [Php](basics/routing.md) -* [Php](basics/dispatching.md) -* [Php](basics/views.md) +* [Routing](basics/routing.md) +* [Dispatching](basics/dispatching.md) +* [Views](basics/views.md) ### Http * [Requests](basics/http/requests.md) From 318c654e8a71c59d413b5a8fc7706801d342b0b3 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 9 Aug 2016 23:51:18 +0200 Subject: [PATCH 3/3] Strucutre, request, response and view --- SUMMARY.md | 10 ++-- basics/http/requests.md | 0 basics/http/responses.md | 0 basics/requests.md | 13 ++++++ basics/responses.md | 9 ++++ basics/views.md | 29 ++++++++++++ ...hing,_sessions,_local_storage_&_cookies.md | 46 ------------------- datastorage/cache.md | 21 +++++++++ datastorage/cookie.md | 7 +++ datastorage/localstorage.md | 1 + datastorage/session.md | 11 +++++ 11 files changed, 95 insertions(+), 52 deletions(-) delete mode 100644 basics/http/requests.md delete mode 100644 basics/http/responses.md create mode 100644 basics/requests.md create mode 100644 basics/responses.md delete mode 100644 components/caching,_sessions,_local_storage_&_cookies.md create mode 100644 datastorage/cookie.md create mode 100644 datastorage/localstorage.md diff --git a/SUMMARY.md b/SUMMARY.md index 8c525c4..ab72b18 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -16,10 +16,8 @@ * [Routing](basics/routing.md) * [Dispatching](basics/dispatching.md) * [Views](basics/views.md) - -### Http -* [Requests](basics/http/requests.md) -* [Responses](basics/htttp/responses.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) diff --git a/basics/http/requests.md b/basics/http/requests.md deleted file mode 100644 index e69de29..0000000 diff --git a/basics/http/responses.md b/basics/http/responses.md deleted file mode 100644 index e69de29..0000000 diff --git a/basics/requests.md b/basics/requests.md new file mode 100644 index 0000000..3833a64 --- /dev/null +++ b/basics/requests.md @@ -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 diff --git a/basics/responses.md b/basics/responses.md new file mode 100644 index 0000000..498840d --- /dev/null +++ b/basics/responses.md @@ -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 diff --git a/basics/views.md b/basics/views.md index e69de29..bd2262e 100644 --- a/basics/views.md +++ b/basics/views.md @@ -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. \ No newline at end of file diff --git a/components/caching,_sessions,_local_storage_&_cookies.md b/components/caching,_sessions,_local_storage_&_cookies.md deleted file mode 100644 index 577bc76..0000000 --- a/components/caching,_sessions,_local_storage_&_cookies.md +++ /dev/null @@ -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 diff --git a/datastorage/cache.md b/datastorage/cache.md index e69de29..378eb61 100644 --- a/datastorage/cache.md +++ b/datastorage/cache.md @@ -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); +``` \ No newline at end of file diff --git a/datastorage/cookie.md b/datastorage/cookie.md new file mode 100644 index 0000000..1c60aa0 --- /dev/null +++ b/datastorage/cookie.md @@ -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 diff --git a/datastorage/localstorage.md b/datastorage/localstorage.md new file mode 100644 index 0000000..8cb5831 --- /dev/null +++ b/datastorage/localstorage.md @@ -0,0 +1 @@ +# LocalStorage \ No newline at end of file diff --git a/datastorage/session.md b/datastorage/session.md index e69de29..307e97d 100644 --- a/datastorage/session.md +++ b/datastorage/session.md @@ -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.