corporate » labs » forge
E29 Incorporated

E29 Product Documentation


Creating the Application

This document will outline how to create your application skeleton.

Generating the skeleton

To create your first application, create the source directory under Serenity's Applications folder:

mkdir /path/to/webroot/sources/applications/$APP_KEY

Where $APP_KEY is the name of your application. We'll use app_hello for this example.

Once you have created the app_hello/ folder under applications/, let's create the index action handler skeleton. We'll bind it to a URL later in the tutorial.

Create the file app_index.php under your app_hello/ folder, and paste the following code into it:

<?php
class App implements serenity_application
 {
 	 public function App()
 	 {
 	 	//
                // Go for it
 	 }
 }
?>

Save the file. Now that the index handler is ready, we'll bind it to a URL and action.

Binding the application to a URL &amp; Host

Now that the application skeleton has been created, it's time to bind it to a host and URL so that it is accessible. From this point on, we can use a web-based interface to manage the applications. You can access the administration interface by typing the following into your browser:

http://your_web_host/app-admin/

Since this is your first application and first use of Serenity AP, you will be prompted to create an administration user and password. This user cannot access any other part of the platform except the web admin. It's encouraged that you do not register a reusable account for the admin account, as you will not have access to any other admin functions in the applications.

Once the user has been created, you will be greeted by a small, concise panel. The application admin system has been built to be simple, straight-forward, and accessible by most browsers and phones. Simply click the 'New Application' link, then enter in 'app_hello' as the application key.

Once you've saved the new application, you can select 'Change Host Binding' from under the Application: app_hello line.

Enter in your top level domain in the first box, and then the key that you want to use to trigger the application. Example:

http://your_web_host/hello

If you wish your application to be on the top level, as in http://your_web_host/, simply enter in an asterisk for the trigger. Example:

http://your_web_host/*

Using an asterisk also causes that particular application to be the catch-all for that particular host.

Adding action handlers

Now that the application has been bound to the host and trigger, it's time to add action handlers. Action handlers are actually bound to PHP code in the applications/ sub directory.

Click the 'Go Back to Application Listing' link at the top of the web panel, and click 'Manage Action Handlers' under the Application: app_hello line. At the bottom of the form, fill out the details for a new action handler using index for the first box, and app_index for the second box.

Click save to add the app_index handler as the catch-all handler for app_hello. Keep in mind that this is just one example, if building a CMS you could pipe all actions into one handler, or split them across modules, etc. Serenity AP is completely flexible in this regard.

Next up: Editing the index action handler

 
developers/tutorials/serenity/hello-world-config.html.txt · Last modified: 2008/07/21 18:03 (external edit)