Hello World!

In this tutorial we assume that you have a SiteFusion server running. We also assume that you are familiar with object oriented programming using the PHP scripting language.

Let's take a look at the directory/file structure for SiteFusion applications first. Applications are stored in the app directory under the sitefusion installation path. The directories in app/ are application groups. Inside one of those an application group, consisting of one or more .startup.php.inc files and probably some libraries and image files. In the example of the SiteFusion Admin utility, the application group is 'sitefusion' (the directory in app/), and the startup file for the application is admin.startup.php.inc. When starting the application from the client, the application textbox should contain 'sitefusion/admin'.

Now, past the SiteFusion app directory and its structure, it’s about time we create our own application. Let’s give it a very original name: ‘testapp’. This application group is included in the release from 5.0.6 onward, and contains all example applications described in these tutorials.

So create a new directory called testapp and within it create a file called helloworld.startup.php.inc. Yes, we’re going to create a nifty Hello World application using SiteFusion!

Open the newly created file and create these two functions:


function authorizeLogin$args$user$pass ) {
    return (
$user == 'user' && $pass == 'password');

getApplication$args ) {

Both are quite self-explanatory: authorizeLogin() checks the user’s credentials. It receives the arguments supplied by the client in a comma-separated list as an array, and the username and password entered. It returns TRUE or FALSE, indication the success of the login. The function getApplication() is called after a successful login and also receives the arguments. It returns the name of the application class we want to start, in this case SFHelloWorld.

After defining these helper functions, we can create the application class, which can be placed in the startup file or in a different file included from there.


class SFHelloWorld extends Application
    public function 
init$event ) {
$this->window->title'Hello World!' );
$this->window->size400300 );
XULLabel("Hello World!")

Again, things are very self-explanatory. Our application extends the Application root class and we define an init() function. This function receives the Event object of the 'initialized' event of the root window. We set the title to 'Hello World!', change the window size to 400x300 and finally, add a label with the text 'Hello World!'.

Save the file and open the client. In the app-textbox, fill in 'testapp/helloworld'. The username and password are 'user' and 'password', as shown hardcoded in our file. Login and enjoy your first SiteFusion Application!

this just sample

ome | 14-01-2013 07:09

Comment on this tutorial
Copy the code: