Real Rapid Application Development

In this tutorial we will review how to create a really fast applications using Tequila framework, we will use the same DB as in First tutorial, but you can use the following techniques with any other DB

We assume:

    • You already download and install Tequila

    • You already created a testing database

    • You already test the application is running

If you haven't done all this, just follow the installation page instructions

Let's get started

1. Add application tables to the DB.

Using your favorite db tool (PHPmyAdmin, SqlYog, command line) execute this script.

DROP TABLE IF EXISTS T_RECIPES;DROP TABLE IF EXISTS T_CATEGORIES;CREATE TABLE T_CATEGORIES ( I_IDCATEGORY int NOT NULL AUTO_INCREMENT, I_NAME varchar(100) NOT NULL DEFAULT '', PRIMARY KEY(I_IDCATEGORY)) engine=InnoDB;;CREATE TABLE T_RECIPES ( I_IDRECIPE int NOT NULL AUTO_INCREMENT, I_IDCATEGORY int NOT NULL, I_TITLE varchar(100) NOT NULL DEFAULT '', I_DESCRIPTION varchar(255) NULL, I_DATE date NULL, I_INSTRUCTIONS text NULL, CONSTRAINT fk_r_c foreign key (I_IDCATEGORY) references T_CATEGORIES(I_IDCATEGORY), PRIMARY KEY(I_IDRECIPE)) engine=InnoDB;

2. Browse to addpage

URL: yourproject/Project1/index.php?task=addpage

* If you give write permissions to the Project1 folder the application should show no errors.

This is the welcome page of Tequila generator "sunrise".

*If you want to edit the details of each page keep reading, if you want to generate the application in one click go to the end of this document

On this page:

    1. On first execution Sunrise generates an XML definition of the application.

    2. Select the radio button Update XML from DB

* You don't need to push any button to save this is a session setting

Click on images for full resolution

3. Check the Table relations

Click on the Table relations link at the top Menu.

On this tab you can see the relation between categories and recipes. For this tutorial we don't need to change anything.

* You can also modify and add relations on this page, this will not modify the DB definition but inform Sunrise of the data relation. We strongly recommend you to capture all your data relations in this page.

4. Create Recipes Page

Follow steps as shown in the illustration.

    1. Select T_RECIPES table

    2. Click on Let me edit the details, this allow you to enter detailed information

    3. Tabs can be toggled (open/close) Click on the 2d to open Related pages

    4. Notice the right control and relation has been preset (if your screen looks different check step 2.2)

    5. Select the size of the controls as shown (optional)

    6. Select a WYSIWYG control, nicedit is included with the source

    7. Un-select the elements that shouldn't appear in the list view (Click on the left one the right will follow)

    8. Add validation for title, to make it a required element

    9. Click the Save button

Click on images for full resolution

5. Create Categories Page

Categories page it's easier, just:

    1. Select T_CATEGORIES table

    2. Click the button to load details

    3. Add validation for category Name (Required)

    4. Click save to generate the page.

Click on images for full resolution

6. Review your hard work!

At this time, your pages have been generated and all the settings you changed saved, if you need to make further changes to this pages, just repeat steps 1,2

View your results:

    1. You can see the generated controllers on: Project1/includes/app/controllers

    2. Browse to: index.php?task=categories

    3. Try adding an empty category to test validation

    4. Try adding "Soups" category using normal "Submit" button

    5. Try adding "Desserts" category using Ajax "Save and Continue"

    6. Exit and see the list of categories

    7. View and edit the information until you are satisfied

    8. Click on view recipes on the list mode

    9. Click on Add a new recipe

    10. Notice the select, description, date controls and Instructions?

    11. Perhaps you want to repeat step 4 and change description for a textarea control? or change the date for a hidden field and set it in the db?

Using RIA's Mashups, XML, Json?

Try adding this "rrt" (requested response types) to the url in any method (view, Browse are nicer to test)

    • index.php?task=recipes&mode=Browse&rrt=block

    • index.php?task=recipes&mode=Browse&rrt=xml

    • index.php?task=recipes&mode=Browse&rrt=json

*New: Check our RIA/FLEX tutorial to see how to link this application!

Regenerating your pages?

Don't worry, the generator makes an MD5 check of all the files, if there is any changes in between the page you are generating and the one stored it will backup the existing file adding the date and time to the name.

Faster? You don't need details?

Maybe you just need a mockup or you don't need to select controls and extra validation.

    1. Click on One App

    2. Click Go.

Tequila DB tables will be ignored, all your files will be created at once.