From 4be28e4a9143baef71d810df20ec114a0796a0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 13:26:45 +0100 Subject: [PATCH 01/10] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85347dc..c4cda97 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Welcome to the wonderful world of Nooku. The aim of this documentation is to introduce some of the important concepts in Nooku for any competent PHP developer, along with some simple to follow examples, in order to get up to speed as quickly as possible. -Nooku is framework like no other, and some of the concepts and design patterns that it uses may not be familiar to you. Fear not, they will be introduced in time and explained in detail where necessary. +Nooku is a framework like no other, and some of the concepts and design patterns that it uses may not be familiar to you. Fear not, they will be introduced in time and explained in detail where necessary. A few assumptions are being made throught these documents: @@ -20,4 +20,4 @@ If you don’t know what these things are, start googling :) To get started, the git repo is at `git://git.assembla.com/nooku-framework.git` -Happy coding! :) \ No newline at end of file +Happy coding! :) From 89d2d1ae4020412c9100cf7f6f8e9d3e0ebafef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 13:32:46 +0100 Subject: [PATCH 02/10] SDK - not SKD ;) --- 01. Introduction/01.2 Concepts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/01. Introduction/01.2 Concepts.md b/01. Introduction/01.2 Concepts.md index cbcee7a..23691b2 100644 --- a/01. Introduction/01.2 Concepts.md +++ b/01. Introduction/01.2 Concepts.md @@ -2,7 +2,7 @@ ## Components -Whilst components aren’t the most important concept, they are pivotal to understanding how Nooku works. Think of Nooku as providing the architecture to build an SKD for the web, a component being akin to a package. Components play a very important role in how Nooku is built now, and how it will develop in the future. Components currently fall into two categories +Whilst components aren’t the most important concept, they are pivotal to understanding how Nooku works. Think of Nooku as providing the architecture to build an SDK for the web, a component being akin to a package. Components play a very important role in how Nooku is built now, and how it will develop in the future. Components currently fall into two categories Dispatchable components (or extensions as they will be know soon) Non-dispatchable components @@ -229,4 +229,4 @@ This is a collection of KDatabaseRows from the database. The object is iterable $rowset->find($id); -The name of rowsets within the view will always be the name of the plural view. \ No newline at end of file +The name of rowsets within the view will always be the name of the plural view. From 33a4f39fd29a960444b03337a259a9f7060019ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 13:39:32 +0100 Subject: [PATCH 03/10] Minor typo fixes. --- 01. Introduction/01.2 Concepts.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/01. Introduction/01.2 Concepts.md b/01. Introduction/01.2 Concepts.md index 23691b2..304f8ee 100644 --- a/01. Introduction/01.2 Concepts.md +++ b/01. Introduction/01.2 Concepts.md @@ -11,14 +11,14 @@ Dispatchable components can be thought of as applications, that can be accessed Non-dispatchable components are components that are used to make other components/extensions. Examples of this might be a category manager, tagging system, version control, comments, etc. -Components are typically built up of controllers,models and views, but can contain a wide array of parts. +Components are typically built up of controllers, models and views, but can contain a wide array of parts. Using the HMVC (more later on the **H**) concepts of Nooku, components can easily be built up from other components, to allow for a great amount of code reuse, and speed up your development lifecycle. ## Service Location -This is one of the most important development concept that you may not be familiar with: +This is one of the most important development concepts that you may not be familiar with: Service location de-couples an object’s class name from its identifier. @@ -59,13 +59,13 @@ Some example identifiers are as follows: com://admin/autos.view.dealers.html So, thats kind of cool yeah? Well, is it really any benefit over doing something like -`new ComFooControllerBar`? Directly, no, not really, infact its a longer string, however, this is where the power or “magic” of nooku comes into play. You don’t need to create the file components/com_foo/controllers/bar.php or the class ComFooControllerBar because Nooku will work out and include the relevant file and instantiate the relevant class for you, based on the identifier. And you will always know that the resource that a particular identifier refers to will be the same resource, regardless of where it is used. +`new ComFooControllerBar`? Directly, no, not really, in fact its a longer string, however, this is where the power or “magic” of nooku comes into play. You don’t need to create the file components/com_foo/controllers/bar.php or the class ComFooControllerBar because Nooku will work out and include the relevant file and instantiate the relevant class for you, based on the identifier. And you will always know that the resource that a particular identifier refers to will be the same resource, regardless of where it is used. Infact, the minimum you may need to do when creating a nooku component, is declare a database table (more on that later) and create a view folder by the name of that table. You can then access and manipulate the data in that table using Nooku’s built in REST API, oh did I forget to mention that? Yeah, there is a REST API built in out of the box, freakin’ cool eh? You can make a REST enabled web application without writing a line of code, seriously, you can (although if you don’t write any code, it wont do alot)! So how does one use this identifier? -Well there are 2 ways of creating an object using an identifier +Well there are 2 ways of creating an object using an identifier: `$object = KServiceManager::get(‘identifier’)` - If the resource is being requested from outside a Nooku class (anything that doesn’t extend \Nooku\Framework\Service) From caa655191dbc000d5e5f12b3826471689e76705e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 14:48:17 +0100 Subject: [PATCH 04/10] Typo --- 01. Introduction/01.2 Concepts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01. Introduction/01.2 Concepts.md b/01. Introduction/01.2 Concepts.md index 304f8ee..f0b03c8 100644 --- a/01. Introduction/01.2 Concepts.md +++ b/01. Introduction/01.2 Concepts.md @@ -219,7 +219,7 @@ There is also a convention of the primary key being the component name, followed If you think about it, these names make a lot of sense. The table always contains multiple rows, thus should be plural. A row is always singular, and thus its primary key should be the singular of the table, followed by _id. Fret not however, Nooku will automatically translate the primary key (whatever you call it) into a property of the name ‘id’. So from your code point of view, just refer to it as $object->id; -When data is requested by the model from the database, data will be returned as one of two object, a KDatabaseRow or a KDatabaseRowset +When data is requested by the model from the database, data will be returned as one of two objects, a KDatabaseRow or a KDatabaseRowset #####KDatabaseRow This is a single object that represents an instance of a row from the database. Rows are saveable and deleteable and hold the data from the DB internally. Columns are accessible as if they were public variables. The name of the row within the view will be the name of the singular view by default. From 52bf040954c7881b9c71fa45bc920e8adb8ef522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 15:01:12 +0100 Subject: [PATCH 05/10] Typo --- 02. Request and Response/02. Request and Response.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02. Request and Response/02. Request and Response.md b/02. Request and Response/02. Request and Response.md index 11f1890..fdf8dca 100644 --- a/02. Request and Response/02. Request and Response.md +++ b/02. Request and Response/02. Request and Response.md @@ -20,7 +20,7 @@ We can think about the above in terms of MVC ![request / response cycle](http://motda.be/nooku/mvc2.jpg) -Nooku is build to model this same process flow through the entire framework. +Nooku is built to model this same process flow through the entire framework. Now think about how in Apache you can load in modules. Modules allow you to extend the existing functionality of Apache, without modifying it's core underlying code. Modules can do all sorts of things, from handling routing (mod_rewrite) to compressing the output sent to the browser (mod_deflate). Nooku employs the same techniques by using an entity known as a behavior. @@ -41,4 +41,4 @@ A dispatcher is responsible for: * Handling exceptions * Returning the response, including the body and the appropriate headers, to the browser -Each component also has a dispatcher. The component's dispatcher is responsible for handling which controller within the component is to be dispatched, authorizes the request, dispatches the request, and returns the response to the caller (the application dispatcher above). \ No newline at end of file +Each component also has a dispatcher. The component's dispatcher is responsible for handling which controller within the component is to be dispatched, authorizes the request, dispatches the request, and returns the response to the caller (the application dispatcher above). From ca0b1df94ba66f3a95c11a48c5b3793d9b5981cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 19:31:33 +0100 Subject: [PATCH 06/10] Missing "to" --- 02. Request and Response/02.1 HMVC.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02. Request and Response/02.1 HMVC.md b/02. Request and Response/02.1 HMVC.md index 3f616ee..22a4df8 100644 --- a/02. Request and Response/02.1 HMVC.md +++ b/02. Request and Response/02.1 HMVC.md @@ -9,7 +9,7 @@ When MVC became a concept that the PHP community started to embrace, OOP softwar ###What's wrong with MVC? -The problem with MVC (in stateless applications) on its own is that it is often considered a very much one shot execution type deal. You make a request to the web server, some handler intercepts the request, works out what controller to load, executes some action on the controller that gets data from the model, sends model data object the view, renders the view and returns the response to the browser. +The problem with MVC (in stateless applications) on its own is that it is often considered a very much one shot execution type deal. You make a request to the web server, some handler intercepts the request, works out what controller to load, executes some action on the controller that gets data from the model, sends model data object to the view, renders the view and returns the response to the browser. ![MVC](http://motda.be/nooku/mvc1.jpg) @@ -63,4 +63,4 @@ And if you need to set specific state information: echo KServiceManager::get('com://admin/component.controller.name')->render(array('id' => 5)); -The above is essentially the same request that would happen as if it came directly from the browser via HTTP, as such, the controller is unaware it was requested internally. Pretty cool eh? \ No newline at end of file +The above is essentially the same request that would happen as if it came directly from the browser via HTTP, as such, the controller is unaware it was requested internally. Pretty cool eh? From dfc81eee7e43b4af4d085784ef58817f1fcfeeca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 19:39:44 +0100 Subject: [PATCH 07/10] Copy/paste mistake: add - not edit --- 02. Request and Response/02.2 BREAD.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02. Request and Response/02.2 BREAD.md b/02. Request and Response/02.2 BREAD.md index 495ea1e..eab660e 100644 --- a/02. Request and Response/02.2 BREAD.md +++ b/02. Request and Response/02.2 BREAD.md @@ -37,7 +37,7 @@ Edit is executed contextually based on the uniqueness of the model state. If the ### Add -The add action modifies an existing record and returns either a 201 (Created) HTTP status, if a new record is created, or an exception is thrown if the record could not be created. +The add action creates a new record and returns either a 201 (Created) HTTP status, if a new record is created, or an exception is thrown if the record could not be created. Add is executed contextually based on the uniqueness of the model state. If the model state is unique, then when issuing an HTTP POST request, an add action will be performed. Add is dispached via the POST action. @@ -57,4 +57,4 @@ Most actions that apply to a record fall into the 5 categories above. If you fin The default controller extends the model controller, so for most controllers that map to records (e.g. database tables), you do not need to create your controller file/class, nooku will handle finding the right controller for you. -Bearing that in mind, if you need to create a view that is not associated with a record, like "checkout" for example, then you must create a controller class that extends `\Nooku\Framework\ControllerView` \ No newline at end of file +Bearing that in mind, if you need to create a view that is not associated with a record, like "checkout" for example, then you must create a controller class that extends `\Nooku\Framework\ControllerView` From 4c4c15da6fe045af98385e894d187382a4bf9226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 19:41:24 +0100 Subject: [PATCH 08/10] (not 100% sure) should read MVC not HMVC --- 02. Request and Response/02.1 HMVC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02. Request and Response/02.1 HMVC.md b/02. Request and Response/02.1 HMVC.md index 22a4df8..ad0d22e 100644 --- a/02. Request and Response/02.1 HMVC.md +++ b/02. Request and Response/02.1 HMVC.md @@ -49,7 +49,7 @@ The image on the left shows a single MVC triad, the image on the right shows a h This allows you to create complex systems out of pre-existing reusable, modular parts, or in Nooku's case, **components**. Each component can be tested on its own, can be built independently and concurrently at the same time as other components, and be re-usable. All this speeds up development and makes your code more structured, and stable. -One of the other major concerns of HMVC is the control aspect. In most MVC implementations, the request for a sub view goes directly to the view, thus bypassing the controller, and any form of ACL that might be implemented. That is BAD! Requests for sub views should go through the controller, this way, all your control logic is loaded just as if the request had come in via HTTP, and everything is kept safe. Also, if your controller implements any form of command chain (as Nooku does) then you want those commands to be executed before/after the request as they may perform crucial manipulations of the input/output. +One of the other major concerns of MVC is the control aspect. In most MVC implementations, the request for a sub view goes directly to the view, thus bypassing the controller, and any form of ACL that might be implemented. That is BAD! Requests for sub views should go through the controller, this way, all your control logic is loaded just as if the request had come in via HTTP, and everything is kept safe. Also, if your controller implements any form of command chain (as Nooku does) then you want those commands to be executed before/after the request as they may perform crucial manipulations of the input/output. ###How? From 0198da794e98879dc2f4b0592bc2a521e69fcd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 19:42:06 +0100 Subject: [PATCH 09/10] Typo --- 02. Request and Response/02.2 BREAD.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02. Request and Response/02.2 BREAD.md b/02. Request and Response/02.2 BREAD.md index eab660e..a2cc87c 100644 --- a/02. Request and Response/02.2 BREAD.md +++ b/02. Request and Response/02.2 BREAD.md @@ -39,7 +39,7 @@ Edit is executed contextually based on the uniqueness of the model state. If the The add action creates a new record and returns either a 201 (Created) HTTP status, if a new record is created, or an exception is thrown if the record could not be created. -Add is executed contextually based on the uniqueness of the model state. If the model state is unique, then when issuing an HTTP POST request, an add action will be performed. Add is dispached via the POST action. +Add is executed contextually based on the uniqueness of the model state. If the model state is unique, then when issuing an HTTP POST request, an add action will be performed. Add is dispatched via the POST action. ### Delete From c88ac3df2a8e3c2176a17f29963cb98d241f5330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babs=20G=C3=B6sgens?= Date: Sat, 25 Jan 2014 19:42:35 +0100 Subject: [PATCH 10/10] Update 02.2 BREAD.md --- 02. Request and Response/02.2 BREAD.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02. Request and Response/02.2 BREAD.md b/02. Request and Response/02.2 BREAD.md index a2cc87c..ae58407 100644 --- a/02. Request and Response/02.2 BREAD.md +++ b/02. Request and Response/02.2 BREAD.md @@ -43,7 +43,7 @@ Add is executed contextually based on the uniqueness of the model state. If the ### Delete -The delete action deletes a record or a set of records. A 204 (No content) HTTP status is returned if the record is deleted, an exception is thrown if not. Delete is dispated directly via the HTTP Delete method. +The delete action deletes a record or a set of records. A 204 (No content) HTTP status is returned if the record is deleted, an exception is thrown if not. Delete is dispatched directly via the HTTP Delete method. ---