simply put: Modules - Information about modules and un-routing URIs to URLs.
Modules
As we've seen before, the configuration fields are separated into top-level namespaces, such as "pie" and "youMixer". In fact, almost everything in PIE is namespaced in this manner. The top-level namespaces are called modules.
Here is a list of places where modules really play a role. Some of these we haven't explored yet:
- Config fields are namespaced: $module/foo/bar
- Event handlers are namespaced: APP_DIR/handlers/$module/...
- Views are namespaced: APP_DIR/views/$module/...
- Dynamically-saved files are namespaced: APP_DIR/files/$module/...
- Classes are namespaced: APP_DIR/classes/$Module/Foo/Bar.php
Modules and Routing
When a request comes in through index.php, the Pie_Dispatcher::dispatch() method runs, and tries to route it to an internal URI.
After routing, if Pie_Dispatcher::uri()->module turns out to be empty (e.g. because no routes matched the requested URL), then the "pie/noModule" event is fired, because PIE doesn't know what to execute next. By default, this event just fires your app's "notFound" event.
When a request comes in, PIE's default "pie/response" handler repeatedly uses the name of the requested module, which it obtains from Pie_Dispatcher::uri()->module.
Routing and Unrouting
Earlier in the guide, we discussed routing -- the process of mapping a URL to an internal URI. Unrouting is the opposite process. To unroute a URI, you call Pie_Uri::url($uri), where $uri is a URI object, an array, or a string of the form "$module/$action ".json_encode($more_fields). For example, you can do:
Pie_Uri::url("youMixer/welcome ".json_encode('facebook' => 1))
Unrouting is used a lot by the Pie_Html class, which is covered in the article entitled "Output". It also makes use of the pie/proxies config field, which is an array consisting of dest url => source url pairs.
Complete reference to PHP ON PIE
TODO: include an iframe with PHPDoc-generated reference