Controllers
The Controller is the part of a module that handles a request. Controllers are responsible for receiving a request, and returning a response. In Alloy, this literally translates to each web-accessible controller method receiving a Request object as the first parameter, and using a return statement to respond with a string, view, or other response type.
Alloy requires you to be a little more explicit about what you want to do within a controller action than most other php frameworks. The rendered content is explicitly set by you issuing a return statement rather than the dispatch loop automatically (implicitly) loading a view template of the same name as the action called, assuming it's going to be there. This is intentional, and allows you greater flexibility over what content is rendered, when, and how.
Method Conventions - RESTful by Default
Web-Accessible controller methods are appended with either "Action" or "Method", depending on the request context. If the action "view" is determined from a matched URL route with a HTTP GET request, the method "viewAction" will be called. Conversely, if the same route is matched with a HTTP DELETE request, the method "deleteMethod" will be called instead. This design prevents incidental deletions and conforms to REST principles because a user will never be able to delete a resource with a simple GET request if you follow this convention.
GET /events/1743
Controller: app/Module/Events/Controller.php
Method: viewAction
GET /users/new
Controller: app/Module/Users/Controller.php
Method: newAction
POST /users/new
Controller: app/Module/Users/Controller.php
Method: postMethod
DELETE /users/new
Controller: app/Module/Users/Controller.php
Method: deleteMethod
All web-accessible controller methods accept exactly one parameter: an \Alloy\Request object. Any named parameters captured or set by the matched route will be set on the request object in the dispatch cycle so they can be easily accessed anywhere in your application.
The "Hello World" Example
Also known as the simplest example possible to make the phrase "Hello World" appear on the screen within the framework's rules and boundaries.