Sign In


Home | Posts | Entry 6

generate restful scaffolding with code stylist for win/mac/lin

Posted February 25th, 2007 by brian

Code Stylist is a graphical development utility which can generate model, view and controller code for Web-database applications. The program is designed to work with the dbscript open source framework, which combines REST-style Web services with content-negotiation. This tutorial will walk you through generating an edit form for records in an SQL database.

step 1

to install code stylist on your workstation, browse to codestylist.com and choose your desktop platform. installation is quick and painless, and it can be completely uninstalled just by deleting the application folder. (windows versions include an uninstaller)

step 2

the codestylist.php file must be placed in your Web server folder. to copy the file, launch the code stylist application and choose the menu item: File > Copy to... pick a destination folder to copy the file to.

in the same folder where codestylist.php is installed, create a folder named site.

screenshot

on linux & mac systems you must set the permissions on the site folder to allow write-access.

screenshot

step 3

click the Setup button in code stylist.

set the Base URL to match the location of your codestylist.php file.

punch in your database settings and click the Verify Setup button to test your configuration.

screenshot

step 4

if you've gotten this far, you're ready to generate some application code. at the bottom left of the code stylist window, click the + button to add a new page.

choose a database table to begin the process.

screenshot

step 5

the mvc generation templates are written in php and can be customized to suit your taste, you will find a range of built-in templates to experiment with.

some templates, such as index.html, can render an unlimited number of database fields, while others such as image.jpg are limited to just one or a few fields.

the file extensions of the templates are designed to tie into the content-negotiation features of the dbscript framework, representations can be chosen automatically by client preference, or explicitly by adding an extension to the url.

screenshot

step 6

check the boxes for the fields to appear on the new page.

drag fields up and down to change their order of appearance.

screenshot

step 7

click on each of the fields to choose what type of form control to use for that field.

screenshot

step 8

choose a name for the new page, in most cases you can accept the default.

screenshot

step 9

now you can see the page that has been generated from the template.

screenshot

and here is the page controller, which will execute before the page is rendered.

screenshot

step 10

click the Publish button to send the generated files to the site folder.

this will forward your browser to the introspection (list of tables) page, from which you can navigate to your generated page.

screenshot

on your desktop you will find a folder named Untitled with all of the generated files. this folder is monitored by code stylist, and any changes you make to the files can be propagated to your site folder by clicking the Publish button in code stylist.

screenshot

updating dbscript

new releases of dbscript are coming out all the time, these instructions will help you update your code stylist installation to use the latest version.

  • download the latest release from http://dbscript.net
  • unzip the archive
  • in your code stylist application folder, find the folder named packages
  • copy the new dbscript files into the packages/dbscript-x.x.x/includes directory
  • in code stylist, choose the menu item: Tools > Erase Site Files
  • click the Setup button, and click Verify Setup to load the updated files

Contributor:

Brian Hendrickson

Created:

Mon Sep 17 02:52 AM





Brian Hendrickson  Fri Sep 21 12:52 AM

awesome!


* Fri Sep 21 12:07 AM





Sign In to post comments







Bookmark this page:







feed
[Valid Atom 1.0]   Valid HTML 4.01 Transitional