This chapter gives you a quick-start guide to Harmoni. It will concentrate on the most common required services: Authentication and Database Connectivity, as well as usage of the architecture.
Here is a run-down of what's in Harmoni:
Get ready, this is hard. And by hard, I really mean easy. Take a look at this code:
require_once("/path/to/harmoni.inc.php");
...
Break it down: the require_once(...) is pretty much it. You include that, before most everything else, in a file called index.php or default.php or whatever you want, really. Once that file is included, all of Harmoni's required classes are included and services are instantiated and configured.
Now, as much as you could claim that your program runs under Harmoni just by using this file, you might also want to take advantage of the functionality it provides.
This section will provide a quick introduction into how Harmoni services can be created, started, stopped and used. For information on specific services that are packaged Harmoni, there is a chapter devoted to just that. This is not it.
Services are, in essence, special PHP classes. They are meant to hover over the execution of your code and pop down whenever you request them to impart their divine knowledge upon you. An example: The ErrorHandler. Any time something bad happens, you throw an error. The error handler picks it up and waits until later to print them out (at your discretion). If the error is fatal, well, it kills your program and tells the end user everything that happened (try it - it's fun).
Harmoni provides a special class called Services which can be used statically. That means that it's available in any scope in your program, and hence your program has access to ALL services registered in ANY scope of your program. For those of you that have a little sense, you organize your code into functions, and maybe even classes and class-methods. No matter where you are, though, you can access the Services class! Amazing! Here's how:
...
if (Services::serviceRunning("ErrorHandler")) {
$errorHandler =& Services::getService("ErrorHandler");
$count = $errorHandler->getNumberOfErrors();
print "We have $count errors!";
}
...
More detail on Services and the more advanced functions can be found later.
This section is a subchapter. Below is its table of contents: