So many technologies so little time to evaluate them, so we decide to write "in a nutshell" introduction to Tequila. What is it?PHP framework for quick, ordered, faster development. For the spec oriented: MVC, Object oriented, UTF8, templates, multiple languages, multiple databases, Data access objects, Value objects, Security ready, User management ready, all code workflow ready, (workflow engine and designer will be shipped in next release) Why it's faster?
Why is better than a normal PHP project?PHP is great !we love it but code can get very messy very fast, using a well structured development style, splitting and reusing your code you will get a better developed project. Easier to maintain, faster to update, ready to be translated or in the worse case scenario ready to use another database! Getting ready to testSetup Tequila
A database to jumpstart your application
What to configureIn: your application/includes/config.php modify:
Depending on your profile / project at this point you might want:
Jumpstart your projectBrowse to : yourserver/yourproject/index.php?task=addpage This is Tequila Sunrise package, it will create an XML definition of your application, you can generate now your application with a single click, or add relations and define page by page which controls to use, validation, etc.. (view rad tutorial) By now you can have all backend ready, some ajax and perhaps many block of your application done. Even better you can revisit page by page and add validations, change controls, adjust their size, add relations. Don't worry Tequila Sunrise create a backup of your file so you never loose hand made changes. Apply your designHeader & footer It's an extended practice in web development to split header and footer, you can find this templates under templates/basic/header.html (and foother.html) * Be careful with header, there are many sections that MUST be there, just copy them into your template! CSSModify the CSS to fit your taste under templates/basic/styles.css Modify the layout CSS: templates/basic/layout.css Style specific pagesEach page / task created has it's own template, just open in your favorite HTML editor. Create a whole new themeCopy / Paste "Basic" folder, Rename the copy as you like. You can switch themes in config.php Start coding your projectCoding in Tequila is very easy, the main issue is to understand how to split your code. Where to the starting coding depends on you, try:
First of all, select a name for the task you want to create, invoices, recipes, inventory, subscriptions, etc.. Running your taskTequila is a single entry point framework, everything is accessed at index.php, to run your taskindex.php?task=yourtask&mode=yourfunctionincontroller Coding the template
What makes a template a template?Tequila uses template Power a really cool engine that allows no coding, so your designer can easily do it, you just:
Example: <!-- START BLOCK : articles --> <tr><td> {articlename} </td></tr> <!--END BLOCK : articles --> Coding the controllerYou know precisely the actions the user can execute? You can add all controller functions at once, in the controller
Rules to write the controller
What you can use to make your life easier
Example, adding a function to search products that have to be reordered: protected function getreorder(&$model, &$view) { $reqCategory = safeRequest('category', 'all'); $data = $model->getreorder($reqCategory); $view->showlist($data); } Coding the modelThe model is any logical class you want to implement normally data access, business rules and all interesting stuff is done here, you can integrate ANY class you already have or code it One rule and some advice
Example: // Using DAO public function getreorder($category == "all") { $dao = new inventory_DAO(); return $dao->getreorder($category); } // Using getData public function getreorder($category =="all) { $mSql = "SELECT * FROM INVENTORY_PRODUCTS WHERE QTY < REORDER"; return getData ($mSql); } Coding the DAO & the VOThe middle point in between your db and your model, you can use: DAO: To get,save,update,find,count records VO: To transport data in an object that represents a ROW in your table Dao takes 3 lines of code: table, votype, keyfield VO, takes 1 line of code: a list of variables, one per field in the db Coding the ViewWe already saw how to make a template, now how to put the data on it? What's there to help me?
Basic (suffering mode)://To create a block: $this->template->newBlock('blockname'); //To replace a placeholder: $this->template->assign('placeholdername', $value); You can create any kind of cycle to assign the data into the template Advanced (Strategies):Strategies, are another way of reuse code across applications, there's many strategies you can use check them out in includes/views Example: Showing the list of products 1 // This will create a beautiful sortable table with any product property you want to display 2 public function showlist($productdata) 3 { 4 $v = new view_alternatetable($this->template, $data); 5 $v->getview(); 6 // To show the same list as XML replace the strategy in line 4 7 $v = new view_xml_data($this->template, $data); 8 9 } Language filesTo create a new language for your system, just copy/paste/rename lang/EN -> lang/YOURLANGCODE
Adding your own CSS / JS filesTequila caches all client resources, so even if you add multiple times the file is requested just one time, you can: 1 addJS("file1.js,file2,js,file3.js"); //<- one or many 2 addCSS("file1.css,file2.css"); 3 addJSVar("varname","varValue"); //<- Ever need to pass a value to the JS script? 4 addJSfromLang ()//<- Pass a JS language file Minimizing, caching and safe loading your JS
$js_safeloading = true; Tequila will now minimize and save a cached reduced file, it will also safe load the file, retrying until the file is loaded or $js_retry is reached, it can also block the screen for using by setting $js_blocktillcomplete = true; $js_safeloading = false; $js_blocktillcomplete = true; $js_retry = 3; $js_cachedir = 'temp'; Setting your application start point and main pageLet's say you want the start point to be login and the main page (after login) to be dashboard Change in config: $defaultpage = "login"; $mainpage = "dashboard"; Adding a login pageNo need to, is already included just set the default page to login or browse to: index.php?task=login Managing your users & securitySecurity is ready in Tequila, also a web editor, just browse to: index.php?task=sec_manager Mashing up!(tutorial coming soon) You can call your pages as blocks from server using getblock(....); or from the browser/client (using rrt querystring parameter). Using rrt you can get a full page, or a block to use inside an iframe or a cleaner piece of code to show in a <div>. JSON and XML are as easily get (check sunrise tutorial) Creating a workflow taskTequila is fully workflow compatible and allows complex interactions, multiple screen changes, interruptions etc, this unfortunately makes impossible for Tequila to automatically knows when you have finished, to inform Tequila just add on the controller: $this->tr->finished = true; If you task return a result that will change the flow $this->tr->result = 'your result'; $this->tr->finished = true; $this->tr->result = true; Creating workflowsWorkflow engine and the designer will be release in version 3.2, we are currently working in the flash based designer which is delaying us, however the engine has been available since version 2.0 Well with this intro in a nutshell, you should be standing on your feet!! Read documentation to learn more or get coding :) Best luck! |

