====== A small example application ======
===== Setup =====
Ok, so let's create our first application using Ismo_Core!
We'll use a directory in the webroot of a web server. If the webroot for the server running on ''foo.bar'' is a ''/var/www/html'' we'll put this small application in a sub directory called Ismo_Core_Example. So let's create that directory:
$ cd /var/www/html
$ mkdir Ismo_Core_Examples
$ cd Ismo_Core_Examples
==== The application class ====
The application class is the entry point, so we'll start with it. Put the following in a file called do.php in the above created directory.
setPath('./states/');
// create the application class
$app =& new Ismo_Core_Application('Ismo_Core_Example');
$app->setStateLoader($loader);
$app->setDefaultState('example');
$app->execute();
?>
We set the default state to be 'example'. That means that ''http://foo.bar/do.php'' will go to the state named example.
==== The state class ====
An application can't do anything without a state so let's create the example state. Put the following in a file named example.php in the above created directory:
Meow";
}
function execHi()
{
echo "Hi
";
}
function execHello()
{
echo "Hello
";
}
}
?>
Now try to go to the following URL's
* http://foo.bar/Ismo_Core_Example/do.php
* http://foo.bar/Ismo_Core_Example/do.php?state=example&action=hi
* http://foo.bar/Ismo_Core_Example/do.php?state=example&action=hello
* http://foo.bar/Ismo_Core_Example/do.php?state=example
==== URL styles ====
Ismo_Core supports two kinds of [[docs:URL styles]], a query parameter based one and a path-info based one. Where will be a chapter in the manual describing these later on.
==== Comments ====
This example was intentionally kept super simple. No templates were used and no database accessed. The files were not protected with a .htaccess file, which should really be done in a real application if the files are located in the webroot.
I left the templates and database access out because Ismo_Core was designed to be template engine independent. There are also many different ways to do database access, all of which should work fine together with Ismo_Core.
The template usage and [[database access]] method will of course vary depending on which solutions you choose for you application. But Ismo_Core will work fine with any choice you make. If you want to provide examples how to use Ismo_Core together with some specific solution, feel free to [[mailto:theideaman@sourceforge.net|send them my way]] or add them to the wiki.