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:
On first execution Sunrise generates an XML definition of the application.
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.
Select T_RECIPES table
Click on Let me edit the details, this allow you to enter detailed information
Tabs can be toggled (open/close) Click on the 2d to open Related pages
Notice the right control and relation has been preset (if your screen looks different check step 2.2)
Select the size of the controls as shown (optional)
Select a WYSIWYG control, nicedit is included with the source
Un-select the elements that shouldn't appear in the list view (Click on the left one the right will follow)
Add validation for title, to make it a required element
Click the Save button
Click on images for full resolution
5. Create Categories Page
Categories page it's easier, just:
Select T_CATEGORIES table
Click the button to load details
Add validation for category Name (Required)
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:
You can see the generated controllers on: Project1/includes/app/controllers
Browse to: index.php?task=categories
Try adding an empty category to test validation
Try adding "Soups" category using normal "Submit" button
Try adding "Desserts" category using Ajax "Save and Continue"
Exit and see the list of categories
View and edit the information until you are satisfied
Click on view recipes on the list mode
Click on Add a new recipe
Notice the select, description, date controls and Instructions?
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.
Click on One App
Click Go.
Tequila DB tables will be ignored, all your files will be created at once.