Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
PHAkt
The InterAKT Dreamweaver MX PHP server model

Originally, I was going to use this article to present a tutorial on using PHAkt in conjunction with PostgreSQL to create dynamic Web sites. However, as I've just returned from MAX 2003 (a nice show, really), my vision changed a bit. I was repeatedly told, "Dreamweaver users don't work with server behaviors - they prefer to code manually."

I decided to shift the focus of this article to include a clearer view of server behaviors as well as the PHAkt product overview.

Introduction
Dreamweaver Ultradev 4 was a great tool for building dynamic Web sites, but did not include support for Apache and PHP, a popular duo.

That's how PHAkt - the PHP Server Model for Dreamweaver - was born. It was the most complex effort of its kind, and it was released as an open source product (free for download) to a huge market success.

PHAkt History
Let me give you a hint: PHAkt comes from PHP and InterAKT. The naming convention has remained since then, even if many people reach us by searching "phpakt".

PHAkt was very popular in the Ultradev 4 era - people downloaded it more than 200.000 times, and we received raves across the board from the Dreamweaver community. But starting with the MX version, Dreamweaver began supporting PHP in the PHP_MySQL server model instead.

"Why would one still need PHAkt?" you might wonder. The answer is simple: PHP_MySQL (as its name implies) can connect only to the MySQL database server. While a large number of Web developers will live with this, some will opt not to use Dreamweaver for PHP development because of its inability to use other databases. Despite its extreme speed, MySQL is still a "toy" database, with no support for triggers, stored procedures, or referential integrity.

Even if you use MySQL, PHAkt can still help you create powerful applications. With a PHAkt site, you will be able to switch to another database later without regenerating all your pages - something impossible with PHP_MySQL.

Web Development with Dreamweaver
Most of today's Web sites are dynamic - the content is stored in the database and rendered on the front end in the visitor browser.

Multiple scripting languages may be used to create dynamic Web sites; you might be familiar with some of them: ASP (Microsoft Active Server Pages), CFM (Macromedia ColdFusion), and JSP (JavaServer Pages). One of the newcomers in this area is PHP (PHP: Hypertext Preprocessor).

To create such Web sites, developers need to create pages that connect to a database and then write the actual HTML output to the client browser (see Image I).

To write script pages, you can use a text editor or you can choose to use a professional tool to leverage your work. Of course, the leader of this latter market is Dreamweaver MX, the best Web IDE.

Despite popular belief, Dreamweaver MX is not only a designer tool, but also a dynamic Web programmer tool. Starting with the fact that 90% of dynamic Web development consists of creating lists with database information and creating forms to update the database, Dreamweaver provides a suite of "server behaviors" to automate those tasks. This is one of the most important features in Dreamweaver MX, and is often not used to its full potential (read "at all").

Server behaviors are reusable code blocks you can use in your Web sites. Aside from the code, they come with a useful GUI that allows you to set various parameters to the code block.

Let's look at one of the most used server behaviors (SBs), the recordset. Its role is to connect to a database, perform a SQL query, and return a recordset (a data structure that will store all the rows and fields returned from the database).

As you can see in Image II, we can set the name and the database connection to be used. Notice that most of the SB interface parameters are bounded properties, meaning that they are dynamically retrieved from the database server without the developer having to memorize or type them.

After you select a database (the database dropdown is loaded with the available database connections), the table menu is updated with all the tables in the current database, and so on.

Applying this SB on the page will output the following code:

<?php
//Connection statement
require_once('Connections/phakt.php');

// begin Recordset
$query_Recordset1 = "SELECT * FROM name_nam";
$Recordset1 = $phakt->SelectLimit($query_Recordset1) or die($phakt->ErrorMsg());
$totalRows_Recordset1 = $Recordset1->RecordCount();
// end Recordset?>

<snip>

$Recordset1->Close();
?>

What makes SBs useful is that they not only generate the code for you, but they also recognize it on the page and allow you to update one code block by loading the configuration interface with all the parameters correctly set. This allows you to change them and reapply the SB. If we go behind the scenes, there is a very complex regular expression engine that stands behind this mechanism, and there are also some limitations in recognizing the already-applied code blocks, but you can easily adapt to them.

Even if some programmers choose not to use SBs ("they restrict my options," "I don't like the generated code," etc.), you should understand that used wisely, they can really improve how you create Web sites.

Picture two situations where you want to create a dynamic Web site:

  1. You are a programming guru. You know how to code, you understand algorithms, SQL, and LEFT JOINs. What you do when creating Web sites (and this means that you list and update information from the database) is a lot of redundant pointing to tables and fields - a very boring task. I don't think anyone in the world enjoys it.
  2. Conversely, you are a Web designer, skilled in HTML and CSS, who wants to make a section of your site dynamic. You don't know any scripting language, SQL, or other complicated programmer notions.
How would SBs help both the programmer and the designer? By writing the code for them. With SBs, the guru would be able to have the boring sections of code automatically generated, saving time for the really interesting stuff, and the designer would have correct script code generated, saving time to focus on the aesthetics of the site.

Enough about SBs. I encourage you to look closely at what they can do for you, as you will be amazed. If you want to find more, Dreamweaver has tons of documentation on them and you will find everything you want in there.

Configuring Your Site for PHAkt
To use PHAkt, you have to install the MXP extension using the Extension Manager. Just go to our PHAkt site and download the product; you will find the phakt-2.6.x.mxp in the PHAkt2 folder. Clicking it should do the install.

You will need access to a computer with Apache, PHP, and a database installed (the database will probably be MySQL, but any database will do).

You will find a lot of information about installing PHP and preparing a workstation for serving dynamic pages at www.dreamweavermxsupport.com.

If you want to test PHAkt at work with another database server, you can get PostgreSQL and install it. PostgreSQL is one of the most advanced open source database servers available, and can compete seriously with any major player in the industry.

Multiple ports for Windows are available; we've found UltraSQL to be the easiest to install (http://techdocs.postgresql.org/guides/Windows).

Once your Apache/PHP server is set up, configure Dreamweaver to edit PHP files using PHAkt. The first step in starting to use PHAkt is to set up the Dreamweaver site (I assume you are already familiar with this, so I won't elaborate)

As shown in Image III, instead of PHP_MySQL, you have to select PHP_ADODB for the Testing Server of your configured site. PHP_ADODB is the server-model name for PHAkt: a confusing naming convention we set up a long time ago, but we have to live with it to keep the backwards compatibility.

When you create new .php files in this type of Dreamweaver site, they will be "stamped" with a small PHP comment in their upper section:

<?php //PHP ADODB document - made with PHAkt 2.6.2?>

This is our way of recognizing a page as a PHAkt page, so you should leave this comment as is. It will not affect your site performance, nor will it be included in your site HTML output.

Improved Database Connection
Let me say this one more time: the most powerful PHAkt feature is its capability to transparently connect to multiple databases from your dynamic Web site. To allow this, we rely on a PHP objects library - ADOdb. Please don't mistake this for the Microsoft ADODB, as they are completely different and share only the API function names.

Our ADOdb (actually it's not ours, it's an open source library written by John Lim - http://php.weblogs.com - but we have improved it a little bit) simply consists of some PHP files that will dynamically choose the correct native database connection library from PHP and use it. When installing a PHAkt site, you will not have to install anything on your PHP server; just copy the site's files and ADOdb will be automatically copied, too.

Let's illustrate the difference between ADOdb and pure PHP code by comparing the native PHP_MySQL code with PHAkt code for a simple SQL query.

The PHP_MySQL code looks like:

mysql_select_db($database_mysql_demo, $mysql_demo);
$query_Recordset1 = "SELECT * FROM name_nam";
$Recordset1 = mysql_query($query_Recordset1, $mysql_demo) or die(mysql_error());

You can see the mysql_* API calls, and it's pretty clear that this code is database specific.

The PHAkt code looks much cleaner, as the SelectLimit() method called is not database specific:

$query_Recordset1 = "SELECT * FROM name_nam";
$Recordset1 = $p->SelectLimit($query_Recordset1) or die($p->ErrorMsg());
$totalRows_Recordset1 = $Recordset1->RecordCount();

Of course, ADOdb will call the mysql_query function, but it uses encapsulation to hide this implementation detail for you.

Creating the Database Connection
In order to benefit from PHAkt's capabilities in a site, you must create a connection from the Databases Panel.

When you click on the + sign, Image IV appears. As you can see, the configuration screen is much more complex than the regular PHP_MySQL database configuration interface. This initial complexity is in fact the window to many useful and available features.

Apart from selecting the database type, you can define a format for the DATE fields in the database and a location for the application messages to be used later in the application. You can also decide whether or not the database connection is persistent (persistent connections use a pool of connections to the database layer to avoid the reconnection time penalty, and thus are slightly faster but more resource intensive).

Supported Databases
PHAkt supports a large list of databases. Unfortunately, we weren't able to test PHAkt effectively on all databases, but the open source community around the ADOdb project did, so you should have a very healthy starting point.

We have used PHAkt mostly with MySQL, PostgreSQL, MsSQL, and Access. We've heard various success stories from our clients who use Oracle, Informix, and Firebird (see Image V).

Once you create the connection, you can start using PHAkt to create Web sites. As we have followed the Macromedia GUI's "unwritten" design rules (believe me, they are *very* strict when it comes to uploading on the Exchange), our interfaces look very similar to the PHP_MySQL ones for all of the server behaviors provided.

Other Improvements
I'll continue the discussion of PHAkt by describing some of the other improvements we've made to help programmers create PHP dynamic Web sites visually.

Date Locales
InterAKT is located in Europe. Because we also do contract work, we have clients around the globe - France, Germany, Australia, the U.S., to name a few - and in creating Web applications for them we've had real problems supporting multiple date formats.

French clients want to edit dates like "m-d-Y", Americans want "Y-m-d", and Germans want "d.m.Y". Because they used MySQL (where you don't have any real way of setting the date locales on the server) on hosted environments (where we can't access the server to change the server locale or anything), we were forced to think of a solution that would allow us to read and write dates in a specific format in the database.

Server Formats from Dreamweaver is a solution when displaying dates, but it can't handle updates at all.

Our solution was to change the ADOdb wrapper and the PHAkt underlying libraries to allow us to set the date locale for a specific connection, and then use this locale transparently when displaying dates and when inserting/updating records in a table. Thus, it's very straightforward for any developer to create internationalized applications (from the date's point of view, at least).

The date-locale support was thoroughly tested with MySQL, PostgreSQL, and MsSQL, but we will continue its implementation based on a client request.

Supplemental Server Behaviors
We have also created PHAkt as a complete server model, providing some features Dreamweaver 6.1 didn't have (MX 2004 seems to have corrected this issue).

When working with PHAkt, you will be able to use:

  • User authentication server behaviors
  • Master/Detail server behaviors
  • Go to Detail Page server behaviors
PHAkt has several other advantages as well.
  • Code reuse: We keep the code that can be reused in a functions.inc.php file that is available when needed.
  • Apache2 header redirect support: In Apache 2 on Windows, relative redirects don't work anymore.
  • Advanced Recordset: This allows you to define other data sources and still reuse the current server behaviors.
This advanced Recordset is probably one of the most powerful features in PHAkt, since we overcome a major Dreamweaver limitation. It normally allows you to use a specific server behavior for only one data source. If you want to define a new data source, for a shopping cart, for example, you will have to reimplement all the features like "Repeat Region", "Show If", etc.

Extending PHAkt
Dreamweaver MX is a platform built with extensibility in mind, extensibility that allowed InterAKT to create PHAkt. Using the same approach, developers around the world can create new features that will plug into Dreamweaver to enable it to support more functionality.

Only a few companies create extensions for PHAkt (they usually focus on PHP_MySQL), but you will find all you need in the list below (shopping cart extensions, query builders, form generators, horizontal looper and nested repeat regions, etc.):

Note: Most of the PHAkt extensions provided by these companies are commercial.

PHP in the Enterprise
Even if PHP has recently been designed from scratch, it has rapidly evolved into a fully featured, easy-to-use programming language for productive, dynamic Web site development.

To get some real information on the PHP market, we conducted extensive market research, and the results may be helpful if you are really serious about PHP. Our research involved 700 respondents, and we managed to get a clearer view on the software development market for PHP and its relationship to medium and large enterprises. Read the survey to see our estimate of the number of PHP developers, the average price of a PHP Web site, and some golden rules to promote PHP in an enterprise setting. Our full market research analysis is located at www.interaktonline.com/index_art_11.html.

Conclusion
Let's take one last look at a summary of PHAkt's features.

Upside
The most important PHAkt feature is its ability to connect to multiple database types. This allows you to create advanced PHP sites, but if you use MySQL, you'll be able to change the database after developing the site without having to re-implement it.

Overall, PHAkt is a step further along in creating PHP sites with Dreamweaver MX, as it integrates a set of improvements that ease software development.

Downside
Unfortunately, there is also a down-side to PHAkt, and the most important is that there are only a few extensions available for PHAkt.

Also, because of the ADOdb usage, PHAkt is slightly slower than native connections, but if you want to create something extensible you will find ways to correct this using various techniques (PHP accelerators, indexes in the database, ete.).

PHAkt's Future
We will continue the work on PHAkt to provide the professional alternative for PHP Web site development in Dreamweaver.

We plan to merge PHAkt with the InterAKT Transaction Engine (tNG), a much better way of creating forms with associated events (send mail, upload image, et.). We want to include PHP 5 support and enlarge the included server behaviors and commands set.

Next Steps
As all regular server model features are present in PHAkt, you can rely on standard Dreamweaver MX Help to get used to the server behaviors and commands.

You will find server behaviors to create lists with records from a Table - Repeat Region, to apply conditional regions - Show if Recordset is Empty, and to create insert, update, and delete forms for a table.

PHAkt also comes with several tutorials and documentation, so you should be able to get started quickly.

I hope you have a better view of what Dreamweaver MX, server behaviors, and PHAkt can do for you. Just go and download our extension and start creating dynamic Web sites now!

Resources

  • PHAkt can be downloaded from the InterAKT Web site:
    www.interaktonline.com/products/PHAkt/
  • Various PHAkt discussions:
    www.interakt.ro/products/bbs/index_0.html
  • ADOdb database abstraction layer:
    http://php.weblogs.com/ADOdb/
  • About Alexandru Costin
    Alexandru Costin is President of Products Division at InterAKT Online. As one of the InterAKT product architects, he has lead the ColdFusion MX7 Extensions project and he is also involved in maintaining the InterAKT suite of Dreamweaver productivity tools.

    He co-authored several books and he posts regularly on Dreamweaver related newsgroups and boards. Reach him at acostin@interaktonline.com

    In order to post a comment you need to be registered and logged in.

    Register | Sign-in

    Reader Feedback: Page 1 of 1

    MySQL is called by a lot of people "toy" database. Nevertheless, in about 10 year it will have a serious share of the enterprise market, and most of our products work with MySQL perfectly. We also use MySQL for almost all our websites and even for some Intranets.

    However, many people don''t think this way - and they have rules to use a specific database server in their company.

    Please also try to not mistake "refferential integrity" with "transactions". They are VERY different.

    Alexandru

    I''m a regular user of Macromedia products namely Homesite. I''ve been developing in PHP/Oracle/MySQL for about 8 years now. I must say that the comment about MySQL being a "toy" database is one of the dumbest things I''ve ever heard. I seriously doubt that many of the large companies that use MySQL would use it if it were a toy database. Also the part about MySQL not supporting referential integrity is totally wrong. MySQL has had support for this since version 3.23 in 2001. Just simply create your tables as InnoDB tables rather than MyIsam for this support. While I don''t consider MySQL to be the perfect db it is far from a "toy". Please know your products before you criticize them.

    The correct product download URL is http://www.interakt.ro/products/PHAkt/

    Alexandru


    Your Feedback
    Alexandru COSTIN wrote: MySQL is called by a lot of people "toy" database. Nevertheless, in about 10 year it will have a serious share of the enterprise market, and most of our products work with MySQL perfectly. We also use MySQL for almost all our websites and even for some Intranets. However, many people don''t think this way - and they have rules to use a specific database server in their company. Please also try to not mistake "refferential integrity" with "transactions". They are VERY different. Alexandru
    Andrew wrote: I''m a regular user of Macromedia products namely Homesite. I''ve been developing in PHP/Oracle/MySQL for about 8 years now. I must say that the comment about MySQL being a "toy" database is one of the dumbest things I''ve ever heard. I seriously doubt that many of the large companies that use MySQL would use it if it were a toy database. Also the part about MySQL not supporting referential integrity is totally wrong. MySQL has had support for this since version 3.23 in 2001. Just simply create your tables as InnoDB tables rather than MyIsam for this support. While I don''t consider MySQL to be the perfect db it is far from a "toy". Please know your products before you criticize them.
    Alexandru COSTIN wrote: The correct product download URL is http://www.interakt.ro/products/PHAkt/ Alexandru
    Latest Cloud Developer Stories
    Can you bring services from the cloud to your customers faster and have them adopt it with ease of use or bring the power of bundled services to the fingertips of your clients without creating new rigid ‘apps stove pipes'? Do you want to prevent your business running away to publ...
    OCZ Technology Group, a provider of high-performance solid-state drives (SSDs) for computing devices and systems, on Tuesday announced the Z-Drive R4 CloudServ PCI Express (PCIe) flash storage solution, designed to accelerate cloud computing applications and reduce operating expe...
    Many organizations have embraced, or are considering, the benefits of cloud computing – speed, flexibility, increased expertise, shared workload, reduced costs, etc. The benefits are many – but so are the risks. What are the threats to cloud security? Which parties assume respons...
    In August 2011, SHI Enterprise Solutions (ESS) division launched the SHI Cloud, offering reliable and cost-effective industrial-grade cloud computing platforms. That same division achieved an 82 percent increase in revenue over 2010.
    SoftLayer Technologies on Tuesday announced the immediate worldwide availability of SoftLayer Object Storage, a redundant and highly scalable cloud storage service that allows users to easily store, search and retrieve data across the Internet, with optional CDN connectivity, or ...
    Subscribe to the World's Most Powerful Newsletters
    Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
    Click to Add our RSS Feeds to the Service of Your Choice:
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
    myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
    Publish Your Article! Please send it to editorial(at)sys-con.com!

    Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

    SYS-CON Featured Whitepapers
    ADS BY GOOGLE