Skip to content
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.

Fixed a few typos and made some small corrections #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions 01. Introduction/01.2 Concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand All @@ -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.
The name of rowsets within the view will always be the name of the plural view.
4 changes: 2 additions & 2 deletions 02. Request and Response/02. Request and Response.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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).
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).
6 changes: 3 additions & 3 deletions 02. Request and Response/02.1 HMVC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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?

Expand All @@ -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?
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?
8 changes: 4 additions & 4 deletions 02. Request and Response/02.2 BREAD.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ 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.
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

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.

---

Expand All @@ -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`
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`
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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! :)
Happy coding! :)