First Basic App

Config

Before we create an example application, make sure that the config file knows to look for your applications instead of the Solar ones. In config/Solar.config.php, find the Solar_Controller_Front config entry and change the it to read like this:

<?php
$config['Solar_Controller_Front'] = array(
    'classes' => array('Example_App'),
    'disable'  => array('base'),
    'default' => 'hello',
    'routing' => array(),
);
?>

Make-App

Now we're ready to make a basic appliction using the make-app command. From the Solar system root, issue the following command will create an example "hello world" application.

$ ./script/solar make-app Example_App_Hello

You will now find the application files at ...

source/
    example/
        Example/
            App/
                Hello.php           # page controller
                Hello/
                    Layout/         
                    Locale/         # app-specific locale strings
                        en_US.php
                    View/
                        index.php   # view script for actionIndex()

Note that the app extends from Example_Controller_Page. If you want the app to extend a different class, use--extends=Some_Other_Cass as a command-line option.

You can now browse to your Solar installation and see the hello application; e.g.:

http://example.com/index.php/hello

As an exercise, modify the output. Edit the Example/App/Hello/View/index.php file to do so.

As another exercise, add a new action. Create an Example_App_Hello::actionWorld() method, and a corresponding world.php view script. You can browse to it by placing the action name at the end of the URI, like this:

http://example.com/index.php/hello/world
 
manual/getting_started/first_basic_app.txt · Last modified: 2009/09/10 10:32 by pmjones