Can any one make sense of this? PHP development

Posted:
in Genius Bar edited January 2014
Ok, so i was assigned a project. making a tickett tracking system. Simple enough, a little MySQL, a little Dreamweaver MX, and a little hand codeing and i would be done. The CEO of my company made the sudgestion that i work with this guy from a sister company, we will call him Brian. Well Brian is a bit of a pureist the following is what he sudgessted we do. So can any one make any sence out of this. I was think that this would be as simple as building the tables and forms to insert data and the reprots. he has a whole diffrent approch. What are your thoughts?



-----------------



Hi Andrew,



I just wanted to give you an update on some thoughts I have on a design

architecture for this and any future projects we may be undertaking

together. I believe that Linux and PHP will be key elements

in leveraging the most advanced technologies to advance our productivity

and profits for our organization. Being a student of PHP for about ten

months now I have learned more optimal ways of designing and developing

more efficiently.



The Goal:

-------------------

We need to develop applications with goals of long-term flexibility and

ease of maintenance. Especially collaborative efforts. We should also

come up with come coding standards that include variable naming, etc,

but this email is only a proposal for application architecture.



The Solution:

---------------------

Designing our application in layers, or tiers. This useful for many

different reasons. Efficient layering can give structure to our

applications, promote scalability, and ease long-term maintenance

requirements for our code. By separating the business logic from the

application logic we effectively preserve the integrity of our

application logic by never having to mix the two.



Here is a prototype of this tiered architecture that I envision for

achieving these goals:





-----------> XLST wrapped HTML

| via Dreamweaver,etc..

/------------------------\\

| PRESENTATION |

| LAYER | ~~~~~~~

\\------------------------/ <-----------------> | BROWSER |

/\\ /\\ ~~~~~~~

|| ||

|| XLST converted to

|| XHTML via PHP Salbatron

||

/----------------------------\\

| REPRESENTATION | <==

| LAYER | ||

\\---------------------------/ ||

||

Template System

(OO PHP Classes output XML)

/\\

/--------------------------\\ ||

| BUSINESS LOGIC| ====

\\--------------------------/

/\\

||

|| <------ Database Abstraction Layer

|| (PEAR DB, ADOdb)

\\/

/------------------------\\

| DATA STORAGE | <-------- Relational Database

\\------------------------/ (MySQL, PostgreSQL)





There are several advantages to using a template system. The primary

advantage is the ability to separate your HTML code from you database

and business logic code. Template systems also allow for easy changes to

the look and feel of your site, proper coding of HTML in your site, and

for the possible separation of the skill sets between us developers

doing the scripting and designers doing the HTML layout of our

application.



Important note: I experimented with the Smarty templating system, and I

uncovered several problems it presents:

1. The Designer has to be introduced to new tags that are not recognized

by and would probably be munged by Dreamweaver. You could change the

"tag style" but...



2. We would have to learn the Smarty way of doing things along with all

of its quirks, syntax, etc...



IMHO the "proper" and complete way to do

templating is to return XML from within a

Class/Function (the "represented" structure) and then XSLT (the

"presented" transform) it into whatever HTML... now THAT is proper way

to do it as XML and XSLT are W3C standards.



Question: Does Dreamweaver allow designers to perform "drag and drop"

visual XSLT?



So the work-flow I propose would work like this:



1. We write our classes.

(The merits of using classes go without saying.)

2. PHP functions return XML via a web service

3. Then Dreamweaver (or tool of your choice) can:

(a) read the XML "prototype" returned from the function, and

(b) perform drag and drop XSLT.

(ie, in practical terms, view the well-formed/DTD'd XML prototype in a

tree structure, rip/drag the leaves into the aforementioned

XSLT-wrapped-HTML doc).







Then, the resulting panacea is that we write functions outputting XMLl

and your designer drags and drops to his/her heart's delight.



Here is an example:



PHP code:

------------------------------------------------

<?

class phpSQLProcessor {

var $doc_element;

var $row_element;

var $query;

var $results;

var $xml;

var $doc_attrs;



--- some functions here ---



/** return XML data from the SQL query **/

function get_xml() {

$rowset = (!empty($this->doc_element)?$this->doc_element:"ROWSET");

$row = (!empty($this->row_element)?$this->row_element:"ROW");

$xml .= "<?xml version=\\"1.0\\"?>\

";

$xml .= "<$rowset";





// adding doc attributes

reset($this->doc_attrs);

while (list($key, $val) = each($this->doc_attrs)) {

$xml .= " $key=\\"$val\\"";

}

$xml .= ">\

";

while ($tab = mysql_fetch_array($this->results, MYSQL_ASSOC)) {

$xml .= " <$row>\

";

reset($tab);

while (list($key, $val) = each($tab)) {

$xml .= " <$key>";

$xml .= $val;



$xml .= "</$key>\

";

}

$xml .= " </$row>\

";

}

$xml .= "</$rowset>\

";

return $xml;

}



-- some error handlers here ---



Now from here we can allow the Dreamweaver guy XLST away then we Turn

XML into HTML with PHP and Sablotron.

<?

include("phpsqlprocessor.inc.php");

/** create a new processor **/

$p = new phpSQLProcessor();



$parser = xslt_create();

if (!$parser)

print xslt_error();

$xsl = join ('', file ('./myStyles.xsl'));

$xml = $p->get_xml();



$h = xslt_process($xsl, $xml, $result);



//print xslt_error();

print $result;

xslt_free($parser);

?>





So, what do you all think?
Sign In or Register to comment.