[Pkg-owncloud-commits] [owncloud-doc] 35/270: add request lifecycle

David Prévot taffit at moszumanska.debian.org
Thu Jul 31 03:52:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud-doc.

commit ea5a4ed47d00b8da4acdb77d958ff43b375ba26e
Author: Bernhard Posselt <dev at bernhard-posselt.com>
Date:   Wed May 7 16:59:14 2014 +0200

    add request lifecycle
---
 developer_manual/app/request.rst | 50 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/developer_manual/app/request.rst b/developer_manual/app/request.rst
index 6268f3d..7db6c19 100644
--- a/developer_manual/app/request.rst
+++ b/developer_manual/app/request.rst
@@ -1,4 +1,52 @@
 Request lifecycle
 =================
 
-.. sectionauthor:: Bernhard Posselt <dev at bernhard-posselt.com>
\ No newline at end of file
+.. sectionauthor:: Bernhard Posselt <dev at bernhard-posselt.com>, Morris Jobke <hey at morrisjobke.de>
+
+A typical HTTP request consists of the following:
+
+* **An URL**: e.g. /index.php/apps/myapp/something
+* **Request Parameters**: e.g. ?something=true&name=tom
+* **A Method**: e.g. GET
+* **Request headers**: e.g. Accept: application/json
+
+The following sections will present an overview over how that request is being processed to provide an in depth view over how ownCloud works. If you are not interested in the internals or don't want to execute anything before and after your controller, feel free to skip this section and continue directly with defining :doc:`your app's routes <routing>`.
+
+Front controller
+----------------
+In the beginning, all requests are sent to ownCloud's :file:`index.php` which in turn executes :file:`lib/base.php`. This file inspects the HTTP headers and abstracts away differences between different webservers and initializes the basic classes. Afterwards the basic apps are being loaded in the following order:
+    
+* Authentication backends
+* Filesystem
+* Logging
+
+The type of the app is determined by inspecting the app's :doc:`configuration file <info>` (:file:`appinfo/info.xml`). Loading apps means that the :doc:`main file <main>` (:file:`appinfo/app.php`) of each installed app is being loaded and executed. That means that if you want to execute code before a specific app is being run, you can place code in your app's :doc:`main` file.
+
+Afterwards the following steps are performed:
+
+* Try to `authenticate the user <userbackend>`
+* Load and execute all the remaining apps' :doc:`main` files
+* Load and run all the routes in the apps' :file:`appinfo/routes.php`
+* Execute the router
+
+Router
+------
+The router parses the :doc:`apps routing files <routing>` (:file:`appinfo/routes.php), inspects the request's **method** and **url**, queries the controller from the :doc:`container` and then passes control to the dispatcher. The dispatcher is responsible for running the hooks (called Middleware) before and after the controller, executing the controller method and rendering the output.
+
+Middleware
+----------
+A :doc:`Middleware <middleware>` is a convenient way to execute common tasks such as custom authentication before or after a :doc:`controller method <controller>` is being run. You can execute code at the following locations:
+    
+* before the call of the controller method
+* after the call of the controller method
+* after an exception is thrown (also if it is thrown from a middleware, e.g. if an authentication fails)
+* before the output is rendered
+
+Container
+---------
+The :doc:`container` is the place where you define all of your classes and in particular all your of controllers. The container is responsible for assembling all of your objects (newing your classes) that should only have one single instance without relying on globals or singletons. If you want to know more about why you should use it and what the benefits are, read up on the topic :doc:`../general/dependencyinjection`
+
+Controller
+----------
+
+The :doc:`controller <controllers>` contains the code that you actually want to run after a request has come in. Think of it like a callback that is executed if everything before went fine.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-doc.git



More information about the Pkg-owncloud-commits mailing list