You are on page 1of 101

Final Year Project Report

Rapid Application Development Framework plus IDE for PHP

By Mohamed Nabeel Mohamed Nasly Sampath Thilakumara Hasitha Gajanayake

Presented to Department of Computer Science & Engineering University of Moratuwa

In partial fulfillment of the requirements for the award of the degree of Bachelor of Science in Engineering. December, 2003.

ii

DECLARATION
We hereby declare that this submission is our own work and that to the best of our knowledge and belief it contains neither material nor facts previously published or written by another person. Further it does not contain material or facts which to a substantial extent has been accepted for the award of any degree of a university or any other institution of tertiary education except where an acknowledgement. Mohamed Nabeel Mohamed Nasly Sampath Thilakumara Hasitha Gajanayake

December 2003.

iii

ACKNOWLEDGEMENTS
PHPlus has been developed successfully with a great contribution of many people in a period of six months. We like to appreciate their guidance, encouragement and willingness since without their support the project would not have been a success. We would like to give our sincere gratitude to Dr. Sanath Jayasena (sanath@cse.mrt.ac.lk), who is the supervisor of our project for helping us in many ways to make our project a success. We are also grateful to Mr. Shantha Fernando (shantha@cse.mrt.ac.lk) who has been behind us guiding all the projects from the very first day and giving us very valuable feedbacks. The project was developed in the latest version of Red Hat Linux (version 9.0 and kernel 2.4) and our project team had to upgrade/install many software packages and libraries to set up the environment. All such libraries and software used were either free or open source. We would like to thank all those involved in free/open source software development and we encourage them to continue their good work. A special thank goes to developers all over the world who have contributed to the mailing lists, we worked with and which was an invaluable source of information to overcome many installation and development challenges. We would also like to thank our Software Engineering lectures, Mr. Samisa Abesinghe and Dr. Chandana Gamage, for their inspiring lectures on the subject and the practical feedbacks. We are also grateful to the whole staff of the Department of Computer Science and Engineering including the head of the department Dr. Ashok Peris, and all the CSE colleagues for their support in many forms and enthusiasm.

PHPlus Team. December, 2003.

iv

ABSTRACT
This report describes the PHPlus (PHPlus), an open source object oriented framework and an IDE (Integrated Development Environment) for rapid web application development using PHP 5
(PHP, PHP5 beta 2) for Linux Platforms. The framework strictly follows the MVC (Model-View-

Controller) architecture where the presentation is clearly separated from the application logic and the approach is completely object oriented. In other words, our framework provides a clear boundary between the tasks of web designers and PHP programmers. This approach makes it possible for web team members to work in parallel which is very important, especially in a commercial, environment to meet customer demands and to take the competitive advantage over other competing software organizations. Further this approach eases the burden of maintaining large and complex web portals. The popularity of any framework largely depends on its ease of use and its integration to a development environment. The framework is closely incorporated with the IDE, which has been developed as part of the project. (The IDE can be used with or without the framework, but it is encouraged to use the framework as it provides many advantages). The IDE provides project management, code editing facilities (syntax highlighting, method discovery, context sensitive help, auto-completion, etc.) , deployment, auto-generation of clients for web services, auto-generation of skeletons of unit test cases, auto-generation of project documentation and CVS (Concurrent Versioning System) support, which are the core functions. The framework together with the IDE truly helps the rapid web application development. PHPlus provides a complete documentation which consists of user guides, developer manuals, API docs and a set of samples. All the software plus the documentation is available at http://phplus.sourceforge.net under free software license. Our future aim is to see PHPlus evolve to the de-facto environment for PHP 5 on Linux platforms.

TABLE OF CONTENTS
DECLARATION.................................................................................................................................iii TABLE OF CONTENTS..................................................................................................................... vi LIST OF FIGURES ........................................................................................................................... viii 1. INTRODUCTION ............................................................................................................................ 1 1.1 Overview .................................................................................................................................... 1 1.2 Importance of an open source framework and an IDE for PHP .................................................... 1 1.3 PHPlus: Framework .................................................................................................................... 2 1.3.1 Components of the Framework............................................................................................. 2 1.3.2 Work Flow of the Framework .............................................................................................. 4 1.4 PHPlus: IDE ............................................................................................................................... 5 1.4.1 Components of the IDE ........................................................................................................ 5 1.5 Project Objectives ....................................................................................................................... 8 1.6 Benefits ...................................................................................................................................... 8 2. LITERATURE REVIEW ............................................................................................................... 10 2.1 C++ Programming in Linux ...................................................................................................... 10 2.2 Qt Programming in Linux ......................................................................................................... 12 2.2.1 Qt object model .................................................................................................................. 12 2.2.2 Signals and slots ................................................................................................................. 13 2.2.3 Qt tools .............................................................................................................................. 14 2.3 PHP Engine .............................................................................................................................. 15 2.4 DOM (Document Object Model)............................................................................................... 15 2.4.1 Programming the DOM ...................................................................................................... 16 6.5 MVC (Model View Controller) ................................................................................................. 16 6.5.1 Importance of the MVC architecture .................................................................................. 17 3. SYSTEM ANALYSIS .................................................................................................................... 19 3.1 Process Model for the project .................................................................................................... 19 3.1.1 Process Model for the Project ............................................................................................. 19 3.2 Requirements Engineering ........................................................................................................ 20 3.2.1 Feasibility Study ................................................................................................................ 21 3.2.2 Requirements Elicitation and Analysis ............................................................................... 22 3.2.3 Requirements Validation .................................................................................................... 23 4. Project Management ....................................................................................................................... 25 4.1 Project Proposal ........................................................................................................................ 25 4.2 Project Planning and Scheduling ............................................................................................... 25 4.3 Risk Management ..................................................................................................................... 26 5. System Design ................................................................................................................................ 29 5.1 Design of the Framework .......................................................................................................... 29 5.2 Design of the PHPlus IDE ......................................................................................................... 31 6. Implementation, Testing and Integration ......................................................................................... 34 6.1 Implementation and Testing of the PHPlus framework .............................................................. 34 6.1.1 XMLCPlus parser .............................................................................................................. 34 6.1.2 Class Library ...................................................................................................................... 37 6.2 Implementation and Testing of the PHPlus IDE ........................................................................ 41 6.2.1 Main Modules in the IDE ................................................................................................... 42 6.2.2 Wizards .............................................................................................................................. 47 7. Future Work ................................................................................................................................... 57 7.1 Framework................................................................................................................................ 58 vi

7.2 IDE ........................................................................................................................................... 58 Conclusion ......................................................................................................................................... 60 References .......................................................................................................................................... 62 Abbreviations ..................................................................................................................................... 65 Appendix A: Project Proposal............................................................................................................. 66 Appendix B: Feasibility Report .......................................................................................................... 72 Appendix C: Risk Management Report ............................................................................................... 76 Appendix D: Requirements Document................................................................................................ 79

vii

LIST OF FIGURES
Figure 1 Work Flow Involved in Using the PHPlus Framework 4 Figure 2 snapshot of PHPlus IDE ... 7 Figure 3 Spiral Process Model with Incremental Development . 19 Figure 4 The Requirements engineering process 21 Figure 5 Project scheduling process ... 25 Figure 6 Risk Management Process 26 Figure 7 Structural Model of the PHPlus Framework 29 Figure 8 PHPlus IDE System Model .. 31 Figure 9 PHPlus - IDE Object Model . 32 Figure 10 Abstract Design of the XMLCPlus parser.. 34 Figure 11 Abstract Design of the Presentation Manager 37 Figure 12 Class hierarchy of DOM Manipulator 38 Figure 13 Layered Architecture of DOM Manipulator ... 39 Figure 14 Snap shot of the IDE highlighting the main windows 41 Figure 15 MDIWindow .. 42 Figure 16 Project Tree ... 43 Figure 17 Method Discovery Logic ... 44 Figure 18 Syntax Highlighting class ... 46 Figure 19 CVS Client Implementation ... 47 Figure 20 XMLCPlus Parser Wizard .. 48 Figure 21 Presentation Generator Wizard ...49 Figure 22 Deployer Wizard 50 Figure 23 Select files to be deployed dialog ... 51 Figure 24 Unit Test Generator 52 Figure 25 PHPDocumentor Wizard 54 Figure 26 SOAP client generator 56

viii

INTRODUCTION
PHPlus is an open source object oriented framework and an IDE for rapid web application development using PHP 5 for Linux Platforms (kernel version 2.4 or higher).

Chapter 1

Introduction

1. INTRODUCTION
1.1 Overview
PHPlus (PHPlus) is an open source object oriented framework and an IDE (Integrated Development Environment) for rapid web application development using PHP 5 (PHP, PHP5 beta
2) for Linux Platforms (kernel version 2.4 or higher). It is carried out as a partial fulfillment of

Computer Science & Engineering, B.Sc. Engineering degree course. The framework strictly follows the MVC (Model-View-Controller) architecture where the presentation is clearly separated from the application logic and the approach is completely object oriented. The framework binds the design and the logic together plus provides a set of API to the developer. IDE, which has the framework in-built, is extremely useful to develop industrial/academic PHP based web applications ranging from small to enormously large in size. IDE has features that one finds in any popular IDE for other languages. A conscious effort was made to provide as many tools and guides as possible to the programmer to reduce the development time.

1.2 Importance of an open source framework and an IDE for PHP


PHP (PHP) is a most widely used server side scripting language and its popularity has grown at a tremendous rate over the last few years. Current statistics (PHP Usage, Nov 2003) show that it is used in over 14 million domains. The main reasons for its popularity are multi-platform support, ease of use, higher performance and being an open source project. PHP allows scripts to be embedded inside HTML pages. When it comes to large-scale business applications, it is experienced that this approach introduces a lot of overhead on future modifications and maintenance of the web site. In many cases it is found that the cost of maintenance far exceeds the cost of development. Many people have identified this problem and some have proposed their solutions in the form of frameworks as well. Eocene
(EOCENE) is one such framework. Even though, these frameworks try to solve the problem mentioned

above, frameworks themselves introduce some serious problems. For example, Eocene uses a set of custom defined tags to generate dynamic content in HTML files and this introduces problems during the designing/redesigning of the web pages. In particular, the visual designing capability is lost and it does not completely separate the logic and the design. Our approach to solve this problem uses widely industry-accepted techniques. Our proposed framework closely follows the principles of Enhydra framework (ENHYDRA), which is used by around one million Java web application developers. Some of the drawbacks of this java-based framework are the resource intensiveness and low responsiveness. PHPlus framework works closely with DOM (DOM Level 1 spec, XML Spec v1) programming of 1

Chapter 1

Introduction

PHP to generate dynamic content and is completely object objected. The framework is written for the latest version of PHP (version 5 beta2, released in Nov 2003, experimental). During the early research on the project, need for an IDE, which is easy to use and install was identified. PHPlus IDE, also open source, provides facilities that one finds in popular IDEs for other languages. The framework is integrated to this IDE to make the web development still faster. IDE provides many wizards to make the life of developers easier. IDE is developed using the Qt (QT) library, which supports multi-platform and in Red Hat Linux 9.0.

1.3 PHPlus: Framework


Open source framework for rapid PHP web application development PHPlus is a completely object oriented framework developed for PHP version 5.0 or higher. It separates out the presentation and the business logic of the web pages, which is the core of any MVC architecture. The framework consists of two main modules. 1. XMLCPlus parser 2. PHP class library. The XMLCPlus parser converts any HTML file (which is XML compliant) in to a PHP class representing the content of the HTML file in PHP Document Object Model. The parser is able to tolerate a level of XML syntax errors. The parser uses XMLWrapp (XMLWRAPP), an open source DOM manipulation library written for C++, to parse HTML files. The PHP class library provides a comprehensive set of functionality to manipulate the PHP DOM class generated by the parser. It also provides facilities to perform frequently used tasks such as database manipulation, editing form controls during run time, etc.

1.3.1 Components of the Framework


A brief description of the modules in the class library is listed below. Presentation Management This module handles incoming page requests and responsible for initialization process for the first request by any user. As a standard, each html file has a corresponding presentation PHP class and that presentation class may in turn utilize one or more business PHP classes.

Chapter 1

Introduction

Database Access Management The user is provided a high-level class library to communicate with external databases. The main advantage of this module is that the user can change the underlying database server with a little or no modification to the existing PHP codes. Session Management Most of the production level web applications require to keep the data across multiple web pages during a user session. This module wraps the session functionalities that PHP engine provides and the user is provided with an easy-to-use interface.

DOM manipulation PHPlus framework is based on the DOM of PHP. Each html file is converted to corresponding PHP class where the content of the html file is represented using the DOM of PHP. The DOM manipulation API provides users with a set of very powerful and easy-to-use functionalities to manipulate the DOM during run time. For example, the API provides methods to populate/clone tables when the result set from a SQL query is supplied as the argument, cutting down a considerable amount of development time.

Form Controls This module provides users with a set of methods to manipulate standard form elements such as combo boxes, text boxes, radio buttons and so on. This facility comes in handy especially when one wants to dynamically update a form element during run time.

Caching Caching improves the subsequent access to the page. The important parameters are what content should be cached and how long it should be cached. These parameters largely depend on the type of content, amount of traffic to the web site and the resources available in the server.

XML Controls XML being a platform independent way of representing data widely used to exchange data thorough the network. This module provides functionalities to manipulate the data and presentation of XML files.

Chapter 1

Introduction

1.3.2 Work Flow of the Framework


Work from Involved in using the framework is illustrated below.
Web designer designed Static pages (eg: welcome.htm) with IDs inserted at the locations where the dynamic content should be generated.

PHPlus Framework Class Library

Business Classes

<html><head> <title> welcome to PHPlus </title></head> <body> <h1> Welcome to the PHPLus framework </h1><br/> <h3> The time is <span id=time> [current time] </span></h3> </body> </html>

<?php /** * XMLCPlus

generated code

XMLCPlus parser

*/ class WelcomeHTML extends DomHTML { } ?>

Presentation classes (eg: WelcomePrese ntation.php)

HTML files displayed on the browser with dynamic content embedded

Parser generated PHP classes (eg: WelcomeHTML.php) which represent HTML data in PHP DOM. High level methods are provided to manipulate the DOM.

PHP Programmer creates these classes

Figure 1 Work Flow Involved in Using the PHPlus Framework

The web designer creates the static html pages, concentrating only on the design aspect of the web pages. The designer usually does not concern about the business logic behind the pages. He/she should work in collaboration with the developer to add ID to the standard HTML tags where dynamic content should be incorporated. It should be noted that every HTML tag supports the ID attribute. For example, if a table should be dynamically filled with data, the designer should insert meaningful Ids to <TABLE> and <TD> tags. Once the static page is ready, it is passed through our PHPlus XMLCPlus parser to produce the PHP version of the HTML file. This PHP file represents the content of the HTML file plus provides a set of methods to manipulate the content through PHP. The manipulation is based on DOM of PHP and it is, therefore, extremely flexible to extend the functionality. Please refer to the user guide
(PHPlus) for more information on how to use our framework.

Chapter 1

Introduction

1.4 PHPlus: IDE


Open source IDE, with PHPlus framework integrated, for Linux platform

PHPlus is an integrated development environment for developing PHP web applications rapidly and painlessly incorporating the features of PHPlus framework. It is developed on the Red Hat Linux 9.0 platform, extensively incorporating the Qt library 3.1. The support for the PHPlus framework is built into the IDE. The developer can call a wizard to parse the web pages designer created to produce the PHPlus framework compliant PHP web application, so he/she needs not to worry about the framework; rather he/she can concentrate on providing functionalities and making the application efficient. To ease the development of web applications and more importantly to make the process faster (note: Time to market largely decides the success of any software project) the IDE supports many of the PHP code editing features such as syntax highlighting, and method discovery. Apart from the code editing features wizards such as documenter, unit test generator are provided to encourage good PHP programming practices. Further, the IDE provides supports for creating clients for SOAP (Simple Object Access Protocol) web services on the fly, keeping up with the current trend of distributed application development. Once the project has been successfully completed, the IDE provides facility to deploy the web site to a web server. Some of the wizards make use of open source libraries to provide the intended functionalities, in keeping with our design goals.

1.4.1 Components of the IDE


Main Application Window The functionalities of the IDE are controlled by this module. This is the module that provides capabilities of a Multiple Document Environment (MDE) to the IDE.

Project Manager This module handles the creation of new projects either from scratch or from an already existing web application and maintenance of the project.

Syntax Highlighter This provides keyword highlighting features for the PHPlus IDE. It can handle both the HTML and PHP syntax highlighting. Since the keyword highlighting rules are extracted from an external database 5

Chapter 1

Introduction

it can cater for future changes in either language. Further, it can easily be extended for syntax highlighting of any other language.

Class Parser It is through this module that the dynamic method discovery is achieved. For this it uses two parsers; dynamic parser and static parser. Static parser implements the logic for parsing a PHP file and the dynamic parser handles the presentation of the features discovered by the static parser. This feature is very essential for rapid application development.

CVS Client When a team of developers work together, it is very important to use a facility to productively share codes among developers without creating any conflicts. Further, one of the most expensive areas of software development is software change management (adding or improving functionalities) and maintenance. The time and cost can be greatly reduced using several techniques. Making use of CVS (Concurrent Versioning System) is one such method. It Keeps track of changes done to the files in web applications by different developers and controls the software versions. This module eases this task by providing a graphical interface for the CVS server. It can handle many of the commonly used CVS commands such as add, commit, update, remove, etc.

Wizards The PHPlus IDE provides several built-in wizards to ease the task of the developer and to facilitate rapid application development by cutting down the time on repeatedly performed tasks. Each of the wizards is briefly described below. o XMLCPlus Parser Wizard XMLCPlus parser, as mentioned earlier, converts any HTML file into a corresponding PHP class. This wizard allows user to generate PHP classes easily and quickly. o Deployer Wizard As the name suggests, Deployer is a graphical tool to deploy the web site to a web server. o Documentor Wizard Documentation is a very essential part of any successful project. The user writes the codes with java-doc compliant comments inserted. This wizard produces a separate documentation

Chapter 1

Introduction

making use of these comments. Open source PEAR::Documentor (PEAR::Documentor) PHP class library is used for this purpose. o Unit Test generator Wizard Testing the web application for making sure older functionalities work as expected when a change is done to one part of the application is not only time consuming but also frustrating activity, if care has not been exercised to incorporate some proven techniques. Unit testing is one such technique widely used in many programming languages. This wizard creates skeleton test cases for any PHP class. Open source PEAR::PHPUNIT (PEAR::PHPUNIT) PHP library is used for this purpose. o SOAP client generator Wizard With web services becoming the de facto standard of developing distribute applications in a platform neutral manner any useful web application should be able to consume the functionalities of web services. This wizard generates SOAP clients for web services which can in turn be used to consume the services provided. Open source PEAR::SOAP (PEAR::SOAP) PHP library is used for this purpose. A screen shot of the IDE is shown below.

Figure 2 snapshot of PHPlus IDE

Chapter 1

Introduction

1.5 Project Objectives


Contribute to the betterment of web-based development using PHP by introducing a very flexible framework. Make Linux a better choice among PHP programmers. Promote the use of PHP as a pure object oriented programming language just like java and C++. Improve the productivity and reduce the cost of web-based development. Device a mechanism to cope with and manage, manage well, the real world problem of constant changes to the web-based projects in the form of either business logic or layout design. Build a CASE/case tool rather than a custom made software so that our end products are used in many custom software developments reaching a larger user community. Make the open source software a better reality. Contribute to the open source software projects by using their end products, suggesting improvements and reporting about bugs. Improve the image of the CSE department by contributing to open source software repository. Improve the knowledge on programming in Linux platform. Develop new/ improve the competency in C++, Qt, and PHP and OO techniques. Further Develop teamwork, project planning and scheduling and soft skills. Promote the use of Linux in major software projects including those that the CSE junior batches will carry out as part of their academic program.

1.6 Benefits
Separation of design and logic help web development teams, which consist of web designers and web programmers, to collaborate effectively and make concurrent activity of team members possible. Inherent organization of the framework introduces a fully object oriented development approach. Faster development is facilitated through the framework plus IDE. Code editing features of IDE reduce the coding time and also the errors introduced during coding. Tools in the IDE give more power to the user and encourage good programming practices such as incorporating testing framework and documentation. IDE helps manage large projects and shared code development. Changes to the application logic/presentation can easily be accommodated. Maintenance cost of web sites can greatly be reduced. 8

LITERATURE REVIEW
All the technologies used with PHPlus are either freely available or open source. Linux, PHP, C++, LibXML2, Apache Axis, PEAR libraries are just to name few.

Chapter 2

Literatur Review

2. LITERATURE REVIEW
2.1 C++ Programming in Linux
Support for C++ Programming in any programming language on any platform, has to basically deal with the following areas. Compilers Library implementations Integrated Development Environments (IDE) Debuggers Build /configuration Tools This fact is equally applicable to C++ programming. Availability of support for the above areas may lead to better and easy programming. For C++ programming on Linux platform, the selection of a particular tool for fulfilling the need for a support may come from quite a good a collection. Some of the most prominent ones among them are listed down below.

Compilers GNU g++ is the most widely used C++ compiler for the Linux/Unix plat form. Open Source and comes default with GNU/Linux distribution. Intel C++ Compiler for Linux is a commercial product with the Compatibility with development tools most programmers already use for Linux application development libstdc++ is a C++ standard library. It is a GNU project and the default compiler for Linux. Current version is libstdc++ v3. gdb is a GNU project and is the debugger mostly used in the Linux platform.

Integrated Development Environments (IDE) KDevelop is a powerful and an easy to use C/C++ IDE publicly available under General Public License. It comes default with Red Hat Linux. The latest version is KDevelop 3.0. It has many code editing features but it lacks better method discovery and auto-completion facilities. KDevelop is not limited to C++. Among the languages it supports are Ada, Java, Perl, PHP, Pascal and Fortran. KDevelop is publicly available under GPL. It can be used with the Qt Designer (explained in the next section) to develop GUI parts. 10

Chapter 2

Literatur Review

Among the features of KDevelop are: Manages all development tools needed for C++ programming, such as the compiler, linker, debugger and build system; A class generator, for creating new classes and integrating them into the current project; File management for sources, headers, documentation etc. to be included in the project; Automatic HTML-based API-documentation for a project's classes with cross-references to the used libraries; Support for managing a project via CVS by providing an easy-to-use front-end for the most needed functions; Integrated debugging A console Syntax highlighting Auto-code completion for class variables, class methods, function arguments and more Four tree views for easily switching between source files, header files, classes and documentation, obviating the need for an external file manager Cross-compiling support, with the ability to specify different compilers, compiler flags, target architecture, etc. Build/configuration Tools Autoconf (http://www.gnu.org/software/autoconf/) is a GNU project. This is an extensible package of m4 macros that produce shell scripts to automatically configure software source code packages Make is also a GNU project and is a build tool. It is used to generate executables by compiling and linking programs and also generates non source files from the source files of the program

Note: The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system. Free Software Foundation (FSF) is the principal organizational sponsor of the GNU Project.

11

Chapter 2

Literatur Review

2.2 Qt Programming in Linux


Introduction Qt (QT) is a multi-platform C++ application framework developed by Trolltech AS, that lets developers write single-source programs that run - natively - on Windows, Linux/Unix, Mac OS X, and embedded Linux. It is also the basis for the open-source desktop environment KDE. 'Qt' is object oriented, component based and has a rich variety of widgets available at the disposal of a programmer to choose from. 'Qt' is available in its commercial versions as 'Qt Professional' and 'Qt Enterprise Editions'. Free edition is allowed to use only in open source projects.

2.2.1 Qt object model


The standard C++ Object Model provides very efficient runtime support for the object paradigm. But the C++ Object Model's static nature is inflexible in certain problem domains. Graphical User Interface programming is a domain that requires both runtime efficiency and a high level of flexibility. Qt provides this, by combining the speed of C++ with the flexibility of the Qt Object Model. Qt adds these features to C++: A very powerful mechanism for seamless object communication called signals and slots; Query-based and designable object properties; Powerful events and event filters, Contextual string translation for internationalization; Sophisticated interval driven timers that make it possible to elegantly integrate many tasks in an event-driven GUI; Hierarchical and query-able object trees that organize object ownership in a natural way; Guarded pointers, QGuardedPtr, that are automatically set to 0 when the referenced object is destroyed, unlike normal C++ pointers which become "dangling pointers" when their objects are destroyed. Many of these Qt features are implemented with standard C++ techniques, based on inheritance from QObject.

12

Chapter 2

Literatur Review

2.2.2 Signals and slots


Signals and slots are used for communication between objects. The signal/slot mechanism is a central feature of Qt. A signal is emitted when a particular event occurs. Qt's widgets have many pre-defined signals, but we can always subclass to add our own. A slot is a function that is called in response to a particular signal. Qt's widgets have many pre-defined slots, but it is common practice to add your own slots so that you can handle the signals that you are interested in. Signals and slots are loosely coupled: a class which emits a signal neither knows nor cares which slots receive the signal. Qt's signals and slots mechanism ensures that if you connect a signal to a slot, the slot will be called with the signal's parameters at the right time. Signals and slots can take any number of arguments of any type and they are completely type safe. All classes that inherit from QObject or one of its subclasses (e.g. QWidget) can contain signals and slots. Signals are emitted by objects when they change their state in a way that may be interesting to the outside world. This is all the object does to communicate. It does not know or care whether anything is receiving the signals it emits. Events and Event filters An event, in Qt, is an object that inherits QEvent class. Events are delivered to objects that inherit QObject through calling QObject::event(). Event delivery means that an event has occurred, the QEvent indicates precisely what, and the QObject needs to react. Most events are specific to QWidget and its subclasses, but there are important events that aren't related to graphics, such as socket activation, which is the event used by QSocketNotifier for its work. Some events come from the window system, e.g. QMouseEvent, some from other sources, e.g. QTimerEvent, and some come from the application program. Qt is symmetric, as usual, so you can send events in exactly the same ways as Qt's own event loop does. An event filter gets to process events before the target object does. The filter's QObject::eventFilter() implementation is called, and can accept or reject the filter, and allow or deny further processing of the event. If all the event filters allow further processing of an event, the event is sent to the target object itself. If one of them stops processing, the target and any later event filters don't get to see the event at all.

13

Chapter 2

Literatur Review

Meta object system The Meta Object System in Qt is responsible for the signal/slot mechanism for communication between objects, runtime type information and the dynamic property system. It is based on three things: QObject class "Q_OBJECT" macro inside the private section of the class declaration and Meta Object Compiler (moc). The moc reads a C++ source file. If it finds one or more class declarations that contain the "Q_OBJECT" macro, it produces another C++ source file which contains the meta object code for this class. This generated source file is either #included into the class' source file or compiled and linked with the class implementation.

2.2.3 Qt tools
Qt Designer The Qt Designer is a visual design tool that makes designing and implementing user interfaces a lot easier. It makes the use of Qt framework for application development. The GUI designing can be done by dragging and dropping components.

Qt Assistant Qt Assistant is the tool for presenting on-line documentation for Qt framework and library. It works in a similar way to a web browser. It is an indispensable tool for any developer who works with Qt library. It is well structured and provides in-depth explanation of each class in the Qt library.

Qmake qmake is the tool used to write Makefiles for different compilers and platforms. Writing makefiles manually can be difficult and error prone, especially if several Makefiles are required for different compiler and platform combinations. With qmake, developers create a simple single 'project' file and run qmake to generate the appropriate Makefiles. qmake is the primary build tool for the Qt library, and for the tools supplied with Qt.

14

Chapter 2

Literatur Review

2.3 PHP Engine


Introduction PHP (PHP) is a most widely used server side scripting language. It is freely available and platform independent (PHP developer community provides two separate versions for Windows and Linux platforms). PHP is more efficient than many other scripting languages such as JSP an ASP. It has a very large developer base. Many industrial applications as well as academic web portals have already been built using PHP. PHP 4.3 is the current stable version. However, PHP is now moving to PHP version 5. They have already release beta 1 and 2. PHP 5 is still under experimental level. Features of PHP 5 beta 2 version PHP 5 beta 2 has some interesting features compared to its previous versions. The main features over the older versions are listed down below.

Improved PHP Object Oriented Support through Zend Engine 2 (Zend Engine 2) Much Tighter, Easier XML Support and uses the latest libxml2 (LIBXML2) library Native SQL support

Zend Engine 2 ZendEngine2 is the core of the PHP 5 version. Not only it has a totally revised object model but also a completely redesigned extension API. The new API makes it possible to quickly write simple OO extensions and to hook deeply into the engine.

2.4 DOM (Document Object Model)


What is XML? XML stands for Extensible Markup Language. XML is a markup language, which is designed to describe data. Being a markup language XML has tags, which must be defined by the user. XML uses a Document Type Definition (DTD) or an XML Schema to describe the data. XML with a DTD or XML Schema is designed to be self-descriptive.

What is DOM? Document Object Model or simply DOM (DOM level 1 spec) represents a tree view of the XML (XML Spec 1.0) document. The DOM is a programming interface XML documents. It defines the way a document can be accessed and manipulated. Using a DOM, a programmer can create a 15

Chapter 2

Literatur Review

document, navigate its structure, and add, modify, or delete its elements. One important objective for the DOM has been to provide a standard programming interface that can be used in a wide variety of environments and applications.

2.4.1 Programming the DOM


Programming the DOM with C++ (http://pmade.org/pjones/software/xmlwrapp/ xmlwrapp library is used for this purpose) Using the DOM of an XML document, a developer can manipulate it. First, the XML document has to be converted to the DOM using a parser and using an API or a library that DOM can be manipulated. xmlwrapp (XMLWRAPP) is such a library, written in C providing a C++ API. It is written by wrapping the libxml2 library. libxml2 is a parser (specifically, a DOM parser) which parses an XML document to the Document Object Model. libxml2 comes by default with Linux distributions.

Programming the DOM with PHP (http://www.php.net DOM section) PHP4 provided an extension called DOMXML for DOM programming. Support for this extension was not provided by default, but could be optionally compiled in. PHP5s DOM support is completely rewritten and is included in the default build.

6.5 MVC (Model View Controller)


The goal of the MVC architecture is to separate the application object (model) from the way it is represented to the user (view) from the way in which the user controls it (controller). The Model object knows about all the data that need to be displayed. It also knows about all the operations that can be applied to transform that object. However, it knows nothing whatever about the GUI, the manner in which the data are to be displayed, nor the GUI actions that are used to manipulate the data. The data are accessed and manipulated through methods that are independent of the GUI. The model represents enterprise data and the business rules that govern access to and updates of this data. Often the model serves as a software approximation to a real-world process, so simple real-world modeling techniques apply when defining the model. The View object refers to the model. It uses the query methods of the model to obtain data from the model and then displays the information. A view renders the contents of a model. It accesses enterprise data through the model and specifies how that data should be presented. It is the view's responsibility to maintain consistency in its presentation when the model changes. The 16

Chapter 2

Literatur Review

Controller object knows about the physical means by which users manipulate data within the model. A controller translates interactions with the view into actions to be performed by the model.

6.5.1 Importance of the MVC architecture


1) Multiple views using the same model: The separation of model and view allows multiple views to use the same enterprise model. Consequently, an enterprise application's model components are easier to implement, test, and maintain, since all access to the model goes through these components.

2) Easier support for new types of clients: To support a new type of client, you simply write a view and controller for it and wire them into the existing enterprise model.

3) Clarity of design: By glancing at the model's public method list, it should be easy to understand how to control the model's behavior. When designing the application, this trait makes the entire program easier to implement and maintain.

4) Efficient modularity: of the design allows any of the components to be swapped in and out as the user or programmer desires - even the model! Changes to one aspect of the program aren't coupled to other aspects, eliminating many nasty debugging situations. Also, development of the various components can progress in parallel, once the interface between the components is clearly defined.

5) Ease of growth: Controllers and views can grow as the model grows; and older versions of the views and controllers can still be used as long as a common interface is maintained.

6) Distributable: With a couple of proxies one can easily distribute any MVC application by only altering the startup method of the application.

17

SYSTEM ANALYSIS
No matter how well designed or well coded, a poorly analyzed and specified software application will not only disappoint the users but also bring grief to the developer.

18

Chapter 3

System Analysis

3. SYSTEM ANALYSIS
3.1 Process Model for the project
When one thinks about other well established engineering disciplines, one can see that each and every activity has a formal approach. Software engineering is still a relatively less matured discipline and there are many software companies who are simply not reaping the benefits of following a standardized approach to software development. This is one of the key reasons why many large projects have failed and in some situations it led to the closure of the organization. The result of such ad-hoc processes was totally unpredictable. As a solution to above mentioned serious problems, engineers have come up with various process models. Although, there is no ideal software process, following either a standard or custom made model is very important for better project management and the production of quality software.

3.1.1 Process Model for the Project


We followed a combination of two standard and very flexible models; spiral model and incremental model. The essence of these models was that the specification was developed in conjunction with the software. Spiral model was used as the main process and an explicit risk management was performed at the beginning of each spiral.

1 Objective Setting

2 Risk Management

Planning

Development and Testing 3 Incremental Development

Figure 3 Spiral Process Model with Incremental Development

Each loop in this process consists of four distinct phases. Setting objectives, discovering the possible risks and identifying the constraints were the activities of the first phase. In the second phase, risks were managed so that the impact of risks was reduced. In the third phase, based on the 19

Chapter 3

System Analysis

incremental model the increment was built or a relevant document was produced. In the final stage of each iteration, status and the progress of the software were reviewed and the project was moved to the next iteration. During this whole exercise we produced the following deliverables; Project proposal Feasibility report and requirements document Design document API docs and user manuals Installation guides Two software increments Our plan to develop the final systems (framework and IDE) was to in two increments. In the first increment, the most important functions were implemented. While the first increment was being developed, further requirements analysis was carried out for the next increment. The first increments of both the framework and the IDE were completed at the beginning of September, 2003 and the user guide & the software were made available for any one to download from our official web site; http://phplus.sourceforge.net. Only the most critical and well-understood functions at that time were in the first increment. In another three months, the second and final increments for both the framework and the IDE were developed and the two increments were integrated together to provide improved functionality.

3.2 Requirements Engineering


This section describes what services are required from the system and the constraints under which the system operates and is developed. This phase of the project is very crucial simply because a small change or an error in this stage invariably leads to considerable amount of rework and may cause serious problems in the subsequent system design and implementation phases. The following diagram (next page) shows the requirements engineering process we followed.

20

Chapter 3

System Analysis

Feasibility study

Requirements elicitation and analysis

Requir ements specification Requirements validation

Feasibility report System models User and system requirements

Requirements document

Figure 4 The Requirements engineering process

3.2.1 Feasibility Study


In any important venture, the first question we want to be clear of is whether it is worth doing it in the first place. There is no difference with software projects as well, irrespective of the domain for which it is built. In this short and focused study we, as a team, made ourselves clear that it is indeed feasible doing this project. During this study we identified a list of questions and information sources in the first place. Based on these questions, we came up with the feasibility report (Appendix B Feasibility Report) analyzing and assessing the questions. Questions The list of identified questions, for which Answers should be found, is given below.

1. Does the project fall within the direct objectives of the department of CSE? 2. How is the project useful for PHP community working mostly on Linux platform? 3. Does the project go inline with our direct objectives? What direct contributions does it make? 4. Does the project require new technologies which our project team has never used before? 5. Can this project be finished on schedule while the academic work is being carried out? 6. Can the project be done using the identified technologies in Linux? 21

Chapter 3

System Analysis

7. Can the whole project be done using free software? 8. Are there any similar projects? Can our project be unique for PHP? 9. How can we acquire knowledge from similar projects done for languages other than PHP? 10. Can the identified technologies be put into work within a month's time from the inception? 11. Can the project be fit into an existing process mode, which consists of a set of activities to come up with the solution? 12. Can this project be convinced that it is innovative and makes most out of the software engineering concepts?

Information sources Developers familiar with the development of similar framework (e.g.: Enhydra developers) Developers familiar with IDE development (e.g.: KDevelop, Qt Designer) Project managers, directors, programmers and designers who are involved in web-based applications. (They may or may not use a framework) (e.g.: Our industry feedbacks receive mostly from experts in CodeGen International, Virtusa and hSenid Software International) Lectures of CSE department including head of the department, project coordinator(s), senior staff and project supervisors CSE colleagues PHP user community and various other user groups who have connection to our objectives and the technologies we are going to use People who are promoting the use and development of free software

3.2.2 Requirements Elicitation and Analysis


Having successfully finished the feasibility study, we decided to analyze the requirements for the project following a formal approach. Our main stakeholders for the project are domain experts, web-based application developers, web designers and project managers mostly from the companies where we underwent the industrial training and the user groups who are using PHP, who develop open source/free software including PHP, Apache Struts, Enhydra, PostgreSQL, Linux, Apache web server, Eocene and Blueshoes. In addition to the stakeholders, our company exposure during the industrial training and the Internet facility provided by the department were very invaluable in this process.

22

Chapter 3

System Analysis

3.2.3 Requirements Validation


To make sure the requirements defined actually reflect the problem definition, several requirements reviews were held with the participation of all the project members as we move along with the project. It was really amazing that we came across subtle points when we listened to how one member elicited a particular requirement(s). We identified that these reviews were very vital for us to have/follow a common objective. For each requirement identified, the following checks were performed. 1. Validity checks. These checks were carried out to ascertain that the functions identified served the intended purpose and that we have not introduced unnecessary functions. 2. Consistency checks If the system is developed when the conflicting requirements are present, it definitely causes problems in the designing and implementation phases. Further, it may badly affect the user acceptance of the system as the user loses the trust with the system. These checks were carried out to remove/amend conflicting requirements. 3. Completeness checks As the name suggests, we made sure that the requirements as a whole defined the total project including the framework and the IDE. 4. Realism checks Requirements were checked for whether they can be implemented with the technologies we decided to use for the project. 5. Verifiability checks Whenever possible we expressed the requirements in quantitative measurement so that team members can ascertain whether the implementation really fulfill the requirement(s).

In addition to the above checks, we made an effort to make the requirements as clear as possible. Further, a special attention was paid to the adaptability of requirements so that requirements changes can be met without a lot of rework. The final result of all the work on the requirements engineering was the requirements document. (Appendix D Requirements Document)

23

PROJECT MANAGEMENT
Project management, the umbrella activity within software engineering, focuses on people, problems and process. Where we areWhere we want to be

24

Chapter 4

Project Management

4. Project Management
Good project management is the key to success of any important software project. Well managed projects rarely fail. Unmanaged or badly managed projects, even with competent people and technologies, have never met the schedule and budget constraints. Project management does not assume that all will go well. Problems of various natures nearly always arise during the life time of the project. This fact should be taken into consideration in all management activities including proposal writing, project planning & scheduling and risk management.

4.1 Project Proposal


One of the first activities in any engineering activity is usually to write a proposal for the project describing the project outcomes, technical requirements, initial schedule (cost estimation and work experience of the engineers in commercial products) and hardware requirements. In a commercial environment, it is very vital for an organization to have many project proposals accepted in order to survive (remain competitive) in the software market where theres a high competition among many companies. Having performed a presentation on the project we were going to embark on, the project proposal was submitted to the department at the beginning of June, 2003. It was accepted, giving us the assurance to continue with our project. (Appendix A - Project proposal)

4.2 Project Planning and Scheduling

Identify activities

Identify activity dependencies

Estimate resources for activities

Allocate people to activities

Create project charts

Software requirements

Activity charts and bar charts

Figure 5 Project scheduling process

The main concentrations on this section are on the work break down, project schedule and monitoring & reporting mechanisms used with the project. Project scheduling is really a challenging task in software engineering. It involves separating out the total work of the project into separate activities and judging the time required to complete these activities. We paid a special attention on providing time for anticipated as well as unanticipated problems. Deliverables and milestones were added to the schedule. Having drawn up the Gantt chart, the activities were divided among the group members. It should be noted that the project schedule was 25

Chapter 4

Project Management

constantly changed through out the project life time to reflect the status at any identified point of time. Provisions were made to cope with and correct the activities those were behind the schedule. Fortnightly, a formal review was carried out to find out where we were and to discuss about the problems that had been encountered and the remedial actions to be taken. Further, a bi-weekly report was compiled and submitted to the project coordinator, Mr. Shantha Fernando, once every two weeks.

4.3 Risk Management


One of the main reasons why many projects are behind the schedule is due to improper risk management. As a team, we identified the possible risks which might badly affect the project schedule or the quality of the software being developed as the first activity of risk management. In our final year projects, we encounter mainly tow types of risks which are project risks and product risks. Project risks affect either the project schedule or the resources. Project risks affect either the quality or the performance of the software being developed. (Appendix C - Risk management
report)

The risk management process we followed is illustrated in the following diagram.

Risk identification

Risk analysis

Risk planning

Risk monitoring

List of potential risks

Prioritised risk list

Risk avoidance and contingency plans

Risk assessment

Figure 6 Risk Management Process

Having identified the risks, they were analyzed according to the probability of occurrence and the seriousness. Probabilities were assessed as five fuzzy levels; very low, low, moderate, high and very high. Similarly, the seriousness of a risk was ranked into four levels; catastrophic, serious, tolerable and insignificant. (Appendix C - Risk management report) Using the above analyzed data, catastrophic and serious risks with moderate or high probability were filtered out as input to the risk planning stage. A special attention was paid so as not to have too 26

Chapter 4

Project Management

many risks in this stage. Otherwise, they not only become unmanageable but also shift the focal point of the project to not so critical activities. To cope with these filtered key risks, strategies were devised based on three mostly used mechanisms; avoidance, minimization and contingency. In the avoidance strategy, the probability that the risk will arise is reduced through counter mechanisms. Minimization insists on the reduction of the impact of the risk whereas contingency approach makes sure that theres an alternative ready if a particular risk occurs. (Appendix C - Risk management report)

27

SYSTEM DESIGN
The beginning of wisdom for a software engineer is to recognize the difference between getting a problem to work, and getting it right. Software design provides the necessary framework for getting it right. -M.A. Jackson-

28

Chapter 5

System Design

5. System Design
Good designs lead to quality software Design of the system largely decides how well the software has been built. Often good designs lead to robust software and make the system so flexible to future changes. As a first step of design, it is usual practice to come up with a software architectural model for the system. Structural models were developed to show the sub-systems and the communication between them. As our project consists of two independent modules, their designs are discussed under two subsections.

5.1 Design of the Framework


The following diagram illustrates the structural model of the PHPlus Framework.

HTTP Request

Presentation Manager CONTROLLER Cache Manager

Class Library

HTTP Response

Presentation Presentation Class 1Presentation Class 2 Class n

A DOM parser to process HTML files and produce corresponding PHP classes

Data Objects Data Objects

Business Objects Business Objects Business Objects

Parser generat ed PHP classes

Parser Engine
HTMLPage HTMLpage HTMLpage

Database Manager

VIEW

MODEL

Static HTML files designed with IDs inserted to the places where dynamic content should be incorporated.

Figure 7 Structural Model of the PHPlus Framework

29

Chapter 5

System Design

The above model shows the subsystems of the framework and the work flow between them. One can see that this closely follows the MVC (Model-View-Controller) architecture. Model stores the data in PHP DOM for each static HTML page. As the data is represented in DOM, it is very flexible to incorporate changes. PHP DOM programming is based on the libxml2
(LIBXML2) library, which is one of the fastest and robust XML manipulation libraries available to the

date. View creates the visual representation of data with the use of the model. In other words, it modifies the model data (i.e. PHP DOM class for a particular static HTML page) and creates new DOM which is almost is ready to send to the user browser. Controller interacts with user to cater for user requests for web pages. When a page request is received, the controller first initializes the paths and required libraries and then selects the correct presentation class to be called. The presentation class, in turn, interacts with the model and view and creates the DOM in PHP for the page request. This modified DOM is converted to HTML by the PHP engine (PHP ENGINE) and sent to the user. It should be noted it is very difficult to draw a clear boundary between the controller and the view as they are so dependent on each other. Nevertheless, we were able to reap several benefits due to the architectural model used. MVC architectural framework has been used in many successful projects, of size ranging from small to large. Apache Struts and Java Swing model are alone enough to justify the statement. Following an industry standard framework to build the architectural model improved the possibility of our project being successful. It is very clear that this architecture helps creating applications conforming to 3-tier architecture. This framework intrinsically encourages modular programming approach to build software. Needless to mention the numerous benefits one gets through modular programming. Based on this model, the whole framework was divided into several sub-modules. They are; HTML to PHP parser (XMLCPlus) PHP Class Libraries o Presentation Manager o Database Manager o DOM Manipulation Library Basic DOM API Table manipulation API 30

Chapter 5

System Design

Web Form Control API XML Control API

o Cache Manager o Session Manger

5.2 Design of the PHPlus IDE


The following diagram shows the system model of the PHPlus IDE.
Configurator CVSManager ProjectManager

ApplicationWindow
XMLCPlus Parser

PHPClassParser

Deployer Wizards SOAP Client Gen Documenter Unit Test Gen DynamicTextParser SyntaxHighlighter
Figure 8 PHPlus IDE System Model

Editor

The main components of the PHPlus IDE Application Window Provides MDI interface and binds all the other modules together Configurator Allow loading/maintaining system configurations Editor Text editor with PHP editing features and HTML editing features ProjectManager General project management facilities PHPClassParser System for parsing PHP files to discover classes, methods and attributes CVSManager Graphical CVS client Wizards Graphical tools for easy access to framework related auto generation and tools for encouraging good programming practices in PHP

31

Chapter 5

System Design

The object model for the PHPlus IDE is shown below.


StaticPHPParser +parseFile() +parseClassDefinition() +parserVarDefinition() +parsefuncDefinition() +parseObjectDefinition() PropertyReader -properties +getProperty() +updatePropery() SyntaxHighlighter -keyWordsMap -functionsMap +highlight()

SystemConstants -propReader -configs

1 1

CVSTabWidget -fileTree -messageViewer


1

FilesTree -commandProcessor +configureCVS() +buildTree() +refreshTree() +addNode() +removeNode() +performCVSOperation()


1 1

ApplicationWindow -menuBar -toolBar -workspace -classAndObjectCollection -cvsDockWindow -explorerDockWindow +parseModifiedFiles() +projectTreeActions() +menubarActions() +editorActions() +showWizards()
1 1

1 1

1 *

MDIWindow -editor -phpParser -syntaxHighlight +load() +save() +loadPreferences()


1 1

Editor -qTextEditor

CommandProcessor -processQueue +processCommand()


1

PHPClassAndObjectCollection -classesMap -objectsMap +addClass() +addObject() +removeClass() +removeObject()


1 1 1

DynamicPHPParser +parseObjDefinition() +discoverMethods() +showPopup() +autoComplete()

ProjectTree +buildTree() +addNode() +removeNode() +renameNode() +createProjectFile() +getFullPath()


* 1

ExplorerTabWidget -projectTree -classesTree

ProjectTreeItem -window

PHPClass -classname -type -extends -interfaces -varMap -functionsMap +addVariable() +addFunction()

* 1

PHPVariable -varName -type

PHPFunc -funcName -type -paramList

Figure 9 PHPlus - IDE Object Model

32

IMPLEMENTATION
From design to working application Coding standards and style, reusability, efficiency and modularity are nuts and bolts of good object oriented programming.

33

Chapter 6

Implementation

6. Implementation, Testing and Integration


As the project consists of two modules (the framework and the IDE) and they are most of the time independent, the development of the two modules were carried out separately two members attending to each module. It should be noted that the framework has been integrated to the IDE and visual assistance provided to work with XMLCPlus parser to convert HTML files into PHP classes. The IDE can also be used without the framework. The class library of PHPlus framework was developed using PHP 5 itself and the XMLCPlus parser was in standard C++. IDE was developed using the Qt library for Linux and standard C++. Performance tester, which is used to test the performance of the web applications, was developed in Java. The whole project was developed only in the Linux platform (Red Hat Linux 9.0).

6.1 Implementation and Testing of the PHPlus framework


6.1.1 XMLCPlus parser
The parser is at the heart of the framework. Its function is to convert HTML files into PHP classes. Its is developed using C++ in Linux. Before the file is fed to the parser, a free software called tidy is used to validate HTML syntax and the user is given the option to select whether he/she want to auto-correct HTML syntax errors. The following diagram illustrates a very high-level abstract design of the parser.

Convert HTML into PHP DOM Pre-parser (Convert HTML to XML syntax)

Add functions to manipulate the DOM

Command Line Interface to the Parser

Build the PHP class and Save to File

Figure 10 Abstract Design of the XMLCPlus parser

34

Chapter 6

Implementation

Preparser takes an HTML file as the input and it modifies the HTML to make it XML compliant. It performs the following functions; Adding self-ending / to tags. Tags which usually dont have an ending tag are listed in a separate tags file. The tag file contains the name of these special tags with each line containing one tag. Every time the parser is called, the tags are read from this file. Preparser checks for these tags if the self-ending character is not found, it is added to it. e.g.: In HTML file <br>, Preparser makes it as <br/> Encoding special characters. XML rules specify that there are certain characters that one cannot use inside text nodes, element names and attribute values. These characters are substituted with a specific pattern and these patterns are decoded by the framework class library before the file is sent to the client browser. e.g.: In HTML file &, Preparser converts it to #38*; Commenting the code of inline scripts. Java scripts and VB scripts contain special characters which the XML parsers cannot handle. As a solution to this, the code inside the <script> tag is commented before being fed to the XML parser. e.g.: Commeted Java script;
<script language=javascript> <!-if (age > 40){ message = you are old; } --> </script>

Removing DOCTYPE nodes. As HTML does not make use of DOCTYPE nodes, they are removed from the file, if found. One main reason for removal is that some popular HTML designers add DOCTYPE without conforming to HTML rules. When these files are sent to the XML parser, it cannot handle them.

Well-formed HTML file is fed to the XML parser. XML manipulation is carried out with the help of a freely available library XMLWrapp (XMLWRAPP). This library is simple and easy to use. However, it does not provide all the XML manipulation functionalities. XML parser creates the DOM tree for the HTML file and using DOM programming, the whole DOM is traversed. For each tag in the HTML file a corresponding PHP statement(s) is added preseving the parent-child relationship. 35

Chapter 6

Implementation

e.g.: For the <HEAD> tag, the following PHP DOM code is created;
$node1 = $node0->AppendChild($this->dom->CreateElement(HEAD"));

For the <!-- This is fun -->, the following PHP DOM code is created;
$node1 = $node0->AppendChild($this->dom->CreateComment (This is fun"));

For the text inside the title, <TITLE>PHPlus Framework </TITLE>, the following PHP DOM code is created;
$node1 = $node0->AppendChild($this->dom->CreateElement(PHPlus Framework"));

For the ID attribute in <SPAN ID=time>server time</SPAN>, the following PHP DOM code is created;
$node0->setAttribute(ID",time);

Note that $node+number depends on the parent-child relationship and the depth of the node. This DOM is created in the constructor of the PHP class to be generated. While all the tags with an ID is stored into an array, for the SPAN and A tags, special methods are added to the PHP class generated. e.g.:
public function setTextTimeid($value){ $this->setTextOfNode('timeid',$value); } public function setLinkLinkid($href, $linkText){ $this->setLinkAndLinkText('linkid',$href,$linkText); } setTextOfNode and setLinkAndLinkText methods are implemented in the parent class

DomHTML. Refer to the implementation details of class library to learn more about the DomHTML class. Radio elements in a form are handled in a special manner. As radio nodes exhibit the property of belonging to a group, they are added to a special array to identify the radio buttons that come under the same group name. e.g.: in the HTML file =>
<input type="radio" name="gender" value="male"> <input type="radio" name="gender" value="female"> <input type="radio" name="gender">

DOM output should be (sample) =>


$this->radioNodes["gender"]["male"] = $node3; $this->radioNodes["gender"]["female"] = $node3; $this->radioNodes["gender"][] = $node3;

The parser provides a command line interface to use it. Its syntax is as follows. 36

Chapter 6

Implementation

xmlcplus html_file1[,html_file2,,html_filen],tag_file[,output_directory]

Parser takes a comma separated list of HTML files and the tag file contains the tags for which self-ending characters should be added. The output can optionally be stored in a directory specified; otherwise generated PHP classes are stored in the same directory where the HTML files reside.

6.1.2 Class Library


Presentation Manager The following diagram illustrates a very high-level abstract design of the presentation manager.

Configuration

Response

Receiver

Controller

Session

Request

Figure 11 Abstract Design of the Presentation Manager

All the page requests come to the Receiver.php (or any other name given to this file) in the form of a GET request. Configuration for the web site is read from an external file. It was decided to use value-property style rather than XML to reduce complexity (processing) of reading properties and to improve the readability. ConfigManager stores all the configuration details. A session is initialized through the session manager. All the request attribute-value pairs (GET, POST and SESSION) are stored in a Request object. ConfigManger and Request objects are fed to the Controller, which then dynamically instantiate the corresponding presentation class. Finally, the receiver gets the string containing the requested HTML file. To reduce the complexity of controlling the framework follows several conventions. All the requests first come to Receiver class. This PHP file can have any name that reflects your sites purpose.
Receiver.php => go to the default page (You can set the default page in Receiver.php file) Receiver.php?page=MyPresentation =>go to MyPresentation.php page

Each PHP file contains only one PHP class and the filename and the class name are equal. 37

Chapter 6

Implementation

Receiver.php should reside in the base directory (this is where you host the site). All the presentation files (e.g.: WelcomePresentation.php) should reside in a sub-folder presentations of the base directory. All the PHP DOM classes should be inside the sub-folder called resources of the base directory. (It is a good practice to keep all the corresponding HTML files inside this folder (but not necessary) for the convenient future references.) All the library classes come with the framework are place in a directory called phplus-lib. Example layout:
mysite /*base directory*/ presentations /*sub directory of mysite*/ WelcomePresentation.php resources /*sub directory of mysite*/ WelcomeHTML.php welcome.html business

DOM Handler Module The separation between the web interface and the application logic of a web application is achieved through the DOM manipulator module. It consists of three main components; The CoreDOM class The DomHTML class (inherited from CoreDOM) Intermediate TemplateHTML class (which is generated by the xmlcplus parser).

The class hierarchy of the DOM manipulator module is as follows.

CoreDOM

DomHTML

TemplateHTML (generated by parser)


Figure 12 Class hierarchy of DOM Manipulator

38

Chapter 6

Implementation

The CoreDom class contains very low level Dom manipulation functions such as cloning nodes with attributes, deep cloning recursively etc. It makes use of the Dom functionality provided by PHP 5, via libxml2. The DomHTML class extends the CoreDom class. It contains more HTML specific manipulation functions such as to set links and link text, append html strings to the DOM etc. and also contains many wrappers such as the dynamic tables wrapper, Database wrapper, XML wrapper, Web form controls wrapper etc. The TemplateHTML class (which extends the DomHTML class) is automatically generated by the xmlcplus parser by parsing the required web page. It contains the code which builds a DOM tree of the given web page, and contains reference points to the nodes with ID tags, which can be dynamically manipulated. The DOM manipulator module has a layered architecture as shown bellow. This architecture allows this module to be highly extensible, providing any additional functionality via wrappers, as required.

TemplateHTML functions

TemplateHTML class

Web-FormControl wrappers

XML wrappers

Database wrappers

Table wrappers

DomHTML class

Medium-level, generic HTML functions CoreDOM class Managed low-level DOM functions

DOM functions in PHP (using libxml2)

Figure 13 Layered Architecture of DOM Manipulator

The basic Dom manipulation is done by manipulating the nodes with reference points set. These are achieved by adding/removing of nodes, 39 cloning of nodes (shallow and deep),

Chapter 6

Implementation

adding/removing/changing node attributes etc. This functionality is provided by the CoreDOM and the DomHTML classes. Wrappers provide high-level functions to make the users life easier. Database wrapper provides functions to directly populate tables using the results of a database query (via the Database Manager). XML wrapper makes it easy to display sets of data directly from a XML file. The web form controls wrapper is very powerful, which allows the user to directly add/remove/change/populate web form controls on a web page. Special care was taken to make sure that no non-standard DOM methods were used in the lower layers, which might lead to code failures with future releases of php & libxml2. Performance was also a main concern when developing the manipulator model, and all functions try to be speedy as much as possible, while retaining the architecture intact. (However, no crude optimizations were done which compromised the extensibility)

Cache Manager Module This is implemented as a single class in CacheManager.php. It provides the facility to cache a complete page or part of a page or any other item such as a result of a complex calculation. The complete page caching can be done when the whole page stays static for a given period of time, while the partial caching can be done on a page which changes frequently, but has a part (eg. a table) which is relatively static. The user can user can specify the lifetime of the cached item, which will expire after that. The cached items will be saved in the /tmp/ folder. The caching is done by saving the DOM tree as a HTML string in a cache file, along with the expiry time. This expiry time is compared with current time when retrieving an item form the cache. Even though the full page caching is straightforward, the partial caching is a bit more complex. When caching a part of a page, the specified node is saved as a HTML string similar to full page caching, but when restoring that part from the cache, its first loaded into a separate dom tree, then cloned, and finally appended to the document at the appropriate position. This carries a performance penalty as compared to full page caching.

Database Manager Module This is implemented as several classes in DbHandler.php. It provides the facility to easily connect to databases through ODBC connectivity. This is actually a simple wrapper for the existing ODBC facilities in php. However the result sets returned by this module is more simpler and intuitive. It also provides the ability to submit the results to the database wrappers in Dom Handler module, 40

Chapter 6

Implementation

which will allow to populate complete tables with a single line or two. Also it provides the ability to use the same methods on the newly integrated SQLite database support in php 5. However this is module is still in a development stage, and requires much more functionality before it reaches its full potential. Advanced functionality such as persistent connectivity etc. is not yet implemented, but will be added along the evolution of the framework.

6.2 Implementation and Testing of the PHPlus IDE


A snap shot of the IDE with main sections highlighted is shown below.

Figure 14 Snap shot of the IDE highlighting the main windows

41

Chapter 6

Implementation

6.2.1 Main Modules in the IDE


Multiple Document Interface (MDI) Environment The MDI workspace provides facilities for working several files loaded in several windows simultaneously. The MDI workspace is created using Qts QWorkspace widget. QWorkspace provides a workspace that can contain decorated windows, in our case MDIWindow widgets, which uses a QTextEdit widget to display the contents. The simplified class diagram of the MDIWindow is shown below.

ApplicationWindow -workspace +newDoc() +save() +showPreferencesDialog() +updateStatusBar()


1

MDIWindow -editor -phpParser -syntaxHighlight +load() +save() +loadPreferences()


1 1 1 1 1

DynamicPHPParser +parseFile()

SyntaxHighlighter +highlight()

Editor -qTextEditor

Figure 15 MDIWindow

The IDEs main window is represented by the ApplicationWindow widget which subclasses QMainWindow widget. This is the entry widget of the IDE. Since QWorkspace does not provide an easy mechanism to switch between loaded windows, a QTabBar widget, which displays currently loaded windows using TabItems, is incorporated to the IDE. A TabItem widget is created sub classing QTabItem class. Note: Refer the API documentation of the PHPlus IDE for a complete description of functionalities provided by the ApplicationWindow widget and the MDIWindow widget.

Project Management This provides facilities for managing files in a project. Currently IDE only supports one type of project. When a new project is created, the project initialization is done through the Project class. The project explorer dock window provides graphical means for managing files in the project. Here the files and directories in the project are displayed in as a tree. For this ProjectTree widget, which sub classes QListView widget is used. A file/directory in the project is represented by the ProjectTreeItem which sub classes QListViewItem. A simplified view of the ProjectTree class is illustrated below. 42

Chapter 6

Implementation

ApplicationWindow -explorerTabWidget
1 1

ExplorerTabWidget -projectTree -classesTree

1 1

ProjectTree ProjectTreeItem -window


* 1

+buildTree() +addNode() +removeNode() +renameNode() +createProjectFile() +getFullPath()

Figure 16 Project Tree

Note: Refer the API documentation of the PHPlus IDE for a complete description of functionalities provided by the ProjectTree widget.

PHP Method Discovery This involved parsing PHP files to identify classes, functions and variables and showing discovered functions and variables when required. The following class diagram illustrates the method discovery logic (next page).

43

Chapter 6

Implementation

StaticPHPParser +parseFile() +parseClassDefinition() +parserVarDefinition() +parsefuncDefinition() +parseObjectDefinition() ApplicationWindow -workspace -classAndObjectCollection +parseModifiedFiles()
1

MDIWindow -phpParser
1 * 1

PHPClassAndObjectCollection -classesMap -objectsMap +addClass() +addObject() +removeClass() +removeObject()


1

1 1

DynamicPHPParser +parseObjDefinition() +discoverMethods() +showPopup()

PHPClass -classname -type -extends -interfaces -varMap -functionsMap +addVariable() +addFunction()

* 1

PHPVariable -varName -type

PHPFunc -funcName -type -paramList

Figure 17 Method Discovery Logic

When a project is open each PHP files in the project is parsed to discover the classes, the functions, the variables and the objects defined. Only the functions and variables that are defined inside a PHP class are parsed. For each class discovered a PHPClass object is created and is added to the classesMap in the classAndObjectsCollection of the MainWindow, so that it can be called when needed. Each class contains separate QMaps for holding functions and variables that belong to the class. PHPFunc class is used for creating objects representing PHP functions and PHPVariable class is used for creating object representing PHP variables. When parsing object definitions those defined inside or outside a PHP class are considered. Each object definition is stored in the objectsMap in the classAndObjectsCollection of the MainWindow. A timer is incorporated to dynamically update the structures. The timer calls the slot for updating of structures in predefined intervals, which can be configured. During updating only those PHP files that are modified since last update are parsed which improves the performance over parsing all the files again and again. The dynamic parser, an instance of which each loaded MDIWindow has, discovers object definitions as and when they are defined and it facilitates method elicitation. It has a slot which is 44

Chapter 6

Implementation

called when ever the text in the editing PHP file is changed. Each time this slot is called it takes actions depending on what the changed text is. The action may be do nothing or addition of new object definition to the objectMap in the classesAndObjectsCollection or identifying methods and variables and showing them in a popup.

Note: Refer the API documentation of the PHPlus IDE for a complete description of functionalities provided by the StaticPHPParser, PHPParser, and PHPClassAndObjectCollection classes.

Syntax Highlighting Todays code editors for almost all the programming and scripting languages come with a syntax highlighting feature. It has become an important and essential feature for code editors. The reason is that it eases the programming task of the developer and also increases the readability of the code while using that particular code editor. With the intention of making the PHPlus IDE a more user friendly one, a syntax highlighter was developed and integrated it to the IDE.

The Syntax highlighter for PHPlus IDE is capable of highlighting PHP syntax for PHP files and HTML syntax for HTML files.

Syntax highlighting for PHP file consists of highlighting the following items PHP keywords PHP built in functions Strings (with single quotes and with double quotes) Numbers PHP variables defined by the developer Single line and multi line comments

Syntax highlighting for HTML files consists of highlighting the following items HTML tags HTML comments HTML attributes and attribute names

Functionality The following diagram presents a simplified picture of the SyntaxHighlight class. 45

Chapter 6

Implementation

ApplicationWindow -workspace
1 *

MDIWindow -syntaxHighlighter -editor

1 1

SyntaxHighlight -wordMap -functionsMap +highlightParagraph()

Figure 18 Syntax Highlighting class

The syntax highlighter for PHPlus IDE is developed by sub classing the Qts QSyntaxHighlighter. QSyntaxHighlighter contains a method called highlightParagraph which has been implemented such that when each time a character is typed, the whole text edit area or the file being edited is parsed. This method is overridden and the syntax highlighting logic is embedded in the resulting method. The PHP keywords and built in functions are stored in a text file. When instantiating a syntax highlighter these files are read and separate map objects of type QMap are populated with the contents in those files. There for when doing the parsing of the target file and highlighting it is easier to access those construct, increasing the performance rather than accessing from a file each time. And also use of external file for storing those constructs, it gives the ability of easily customizing the highlighter for future versions of PHP or even for a separate purpose. The PHP files and the HTML files are identified separately by the extension for the file. i.e. .php or .PHP for PHP files and .html or .htm for HTML files.

Note: Refer the API documentation of the PHPlus IDE for a complete description of functionalities provided by the SyntaxHighlight class.

CVS Client A CVS client is built into to the IDE as keeping track of the changes done to source files is vital in any team project. The operations enabled through the graphical CVS client are add file(s), remove file(s), commit file(s), update file(s), view status of file(s). The CVS files tree is implemented instantiating FilesTree widget and it sub classes the QListView widget. When a CVS operation is requested through the context menu of the tree, it is send to the CommandProcessor which queues the operations and execute one by one. The CommandProcessor is implemented sub classing the QProcess 46

Chapter 6

Implementation

class which allows executing Linux native commands. For showing the status of files an icon set is used. The tree displays each file in the working copy with a color and an icon which reflects the status of the file. In the current implementation once the files are changed the refreshing should be done manually to see the current status of the files. A simplified picture of the CVS FilesTree widget is given below.

ApplicationWindow -cvsDockWindow
1 1

CVSTabWidget -fileTree -messageViewer

1 1

CommandProcessor -processQueue +processCommand()

FilesTree -commandProcessor +configureCVS() +buildTree() +refreshTree() +addNode() +removeNode() +performCVSOperation()

Figure 19 CVS Client Implementation

Note: Refer the API documentation of the PHPlus IDE for a complete description of functionalities provided by the FilesTree widget and the CommandProcessor class.

6.2.2 Wizards
XMLCPlus Parser Wizard This is the wizard for converting HTML files to corresponding PHP DOM classes. The wizard is implemented using QDialog widget. The interface is defined in the .ui file and the implementation is provided in the corresponding .ui.h file. When the dialog is displayed, the available files list box is filled with all the HTML files found in the current project.

47

Chapter 6

Implementation

Figure 20 XMLCPlus Parser Wizard

Once the user selects the necessary files and press compile button, each of the selected files paths along with the necessary parameters to call the XMLCPlus executable is send to the Command Processor. The command processor queues the requests and process each request one after the other. Each process results in a new file if successful. The output messages generated by the parser are displayed under the messages tab. After parsing each file, a signal is emitted indicating that the process is finished. This signal is used for updating the project tree and the project file by adding the new file being created. If the XMLCPlus parser is unable to run for some reason, then an appropriate error message is shown.

Presentation Class Generator Wizard This is the wizard for creating Presentation classes delegating corresponding PHP DOM classes. The wizard is implemented using QDialog widget. The interface is defined in the .ui file and the implementation is provided in the corresponding .ui.h file. When the dialog is displayed, the available files list box is filled with all the PHP DOMs found in the current project.

48

Chapter 6

Implementation

Figure 21 Presentation Generator Wizard

Once the user selects the necessary DOMs and press Generate, for each DOM class a presentation class is created in the presentation directory of the project. The presentation class generated solely depends on the path of the DOM. After creation of each presentation file, a signal is emitted so that the newly created file can be added to the project tree and the project file can be updated. Messages generated during the presentation file creation are displayed under the messages tab.

Project Deploy Wizard Purpose Once a web application is developed using the PHPlus framework, it has to be deployed in a web server to be accessed over the web. This deployment consists of copying the necessary files from the project directory into the root directory of the web server (i.e. the folder in which web content should lie) and creating the configuration file which is needed by the web application. To ease this deployment task, a deploy wizard was developed and integrated to the IDE. Therefore the developer is able to deploy the project in the web server with this tool, by only entering the needed information. In the current version it is only possible to deploy the project in the web server in the current computer. The deployment of the project in a remote computer is to be done in the following versions.

Functionality and Usage The Project Deploy Wizard is a Dialog with a tab widget having three tab panes as shown in figure below.

49

Chapter 6

Implementation

Figure 22 Deployer Wizard

The user has to enter the path to the web root where the project to be deployed. Clicking of the button right hand to the text field opens a file dialog which makes entering the web root easier. User has to give a base directory in which the project will be deployed. If a folder with the entered name already exists there, the user is informed in a later stage. The combo box right to the Default page label contains all the PHP files in the presentation directory in the project. User can select one, and it will be the default page for the web application. User also has to enter the path to the receiver.php file of the web application. Selection of Enable Debug and Enable Session inserts the corresponding details in the configuration file for the web application and those values are used by the framework. When the Next button is clicked, the Content pane is shown as in figure below (next page).

50

Chapter 6

Implementation

Figure 23 Select files to be deployed dialog

The user can select the content to be deployed. Back button can be used to go back to the Configuration pane. Once the Deploy button is clicked, the user is informed If a directory already exists by the name entered as the base directory If user has not entered all the details If user has already deployed the project before

When the Deploy button is clicked the Message pane is showed, which list all the deployment details, the success of the deployment or the failure.

Unit Test Class Skeleton Generator Tool Software testing is a part of Verification and Validation. Verification and Validation (V & V) is the checking and analysis process that ensures the software being developed confirms to its specification and meets user requirements. Verification and Validation are clearly two different things since validation is checking whether the right product is being built and verification is checking whether the product is being built right.

Unit Testing

51

Chapter 6

Implementation

Unit Tests are programs written to run in batches and may consist of several test classes. Each typically sends a class a fixed message and verifies it returns the predicted answer. Unit Tests are a key component of software engineering. Developers write tests for every class they produce. The tests are intended to test every aspect of the class that could conceivably not work.

Purpose Since unit testing is a part of the developers work, he/she is responsible for writing test classes. If there is a way of generating test class skeletons for the test classes to be written, it would ease the task of the developer. Identifying this requirement, the Unit Test Class Skeleton generator was developed.

Usage The tool consists of a simple dialog form, as show below.

Figure 24 Unit Test Generator

User has to enter the Source Directory in which the PHP classes of which test classes are needed and the Output Directory in which the created test classes will be stored. The default output directory is set to tests directory in the project directory. If tests directory does not exist, it is created. Other than the test classes for the classes in the given directory, a TestSuite class is also created.

Functionality 52

Chapter 6

Implementation

This tool generates test class skeletons for all the PHP classes in a given folder targeting a unit test framework for PHP called PHPUnit. Note: PHPUnit is a regression testing framework used by the developer who implements unit tests in PHP. PHPUnit is a package distributed with Pear. Refer http://pear.php.net/package/PHPUnit for further details. Refer the installation documentation for PHPlus IDE for installing PHPUnit library, if you havent installed it yet. To perform the testing using the test class skeletons generated, the PHPUnit.php script which is the PHPUnit framework should be available. It should lie in the same directory as the test classes or the correct path should be inserted in the generated classes. Once the test class skeletons are generated, they should be filled by the developer. The test is done by simply accessing the TestSuite.php through the browser.

PHP Documenter Tool Purpose In any software project, documentation holds an important role in many ways. This is true for a web application too. Writing good documentation is essential to the success of any software project. The quality of documentation can be even more important than the quality of the code itself, as a good first impression will prompt developers to look further into your code. Identifying this requirement a Documenter tool was developed and integrated to the IDE. This tool can be used to produce Documentation for classes in given one or more directories, in HTML format or PDF format. It uses the third party library PHPDocumentor (release 1.2.3) (http://pear.php.net/package/PHPDocumentor), which generates PHP documentation and provides the user with a user friendly GUI to use that particular library. By using this tool, all the PHPlus projects developed can have consistent documentation. Refer the installation document of the PHPlus IDE for installing PHPDocumentor if you havent installed it yet. Usage The tool was developed as a dialog with a tab widget having two panes as shown below.

53

Chapter 6

Implementation

Figure 25 PHPDocumentor Wizard

The Documenter pane contains some fields to be filled by the user. Below the Select Source Directories label is a multi select list box. It lists all the directories in the project directory. The User has to select one or more directories, which he intends to, produce documents. Output directory is the place where all the produced documents are stored. As mentioned earlier the documentation can be created in two formats, HTML and PDF. The Select Type combo box enables the user to select one type. Once all the details are entered and the Produce button is clicked, the Massage pane is showed. It shows the detail of the documents produced.

Functionality The tool is completely developed using Qt library for C++. It uses an object of QProcess class in Qt library. QProcess class is used to invoke processes providing a way to execute external processes in a program. The command used to call phpdoc (mentioned earlier) is wrapped in a QProcess object and executed.

54

Chapter 6

Implementation

Web Services Client Proxy Generator Tool Purpose To consume a web service, a proxy is needed. A proxy is a local object with the same interface as the actual web service; it allows you to call the web service as if it were a local object. Using the proxy, a client can be developed to consume the target Web Service. The straight forward way of getting a proxy is developing it by looking at the relevant WSDL file. This tool generates the proxy for the user. The only needed information by this tool is the path to the WSDL file for the web service to be used. The tool uses a third party library called PEAR::SOAP (Version 0.8RC2) and provides the user with a user friendly GUI to use that library.

Refer http://pear.php.net/package/SOAP to learn about PEAR::SOAP Refer the installation document for the PHPlus IDE for installing PEAR::SOAP, if you havent installed it yet.

Functionality For the WSDL of the targeted Web Services PEAR::SOAP generates a proxy. To consume the Web Service in a PHP project the client class is needed. This can be written by looking at the WSDL, but it is a difficult work. The PHP SOAP client generates this file making the consuming of the Web Service easier. A separate PHP script was written to generate the above file using the output of PEAR::SOAP mentioned earlier. The GUI calls this PHP script and stores the generated file in the entered output directory. The tool is developed completely using the C++ Qt library.

Usage The tool is developed to be consisted of a tab widget with two panes, one for entering the necessary information (see Figure SOAP client generator) and the other one for displaying the messages to the user about the generation of the proxy.

55

Chapter 6

Implementation

Figure 26 SOAP client generator

The text box left to the label Path to WSDL has to be filled with the URL to the WSDL of the Web Services to be consumed. The output directory or the directory in which the proxy file is created has to be entered in the bottom text box. The button right to that text box provides a easy way of selecting a directory through a file dialog. After entering the details, clicking the Generate button creates the client proxy. The Message pane is automatically shown with the details of the creation of the proxy.

56

FUTURE WORK
It would be a miracle if a software system is 100% free from bugs and provides all the functionalities in the world. Rather a software system should evolve to have more functionality and less bugs with the time.

57

Chapter 7

Future Work

7. Future Work
7.1 Framework
The PHPlus framework is extremely young, compared to the other well accepted web development frameworks such as Enhydra and Apache struts. It has a long way to go before it matures into its full potential, even though it is already very powerful and usable.

Some of the identified improvements required for the framework are as follows;

A complete Exception Handling Model. A full blown exception handling model for the framework would greatly improve its usability. Since PHP 5 supports the exception model by default this should be easy to implement. Fault Tolerance in the XMLCPlus parser tool Currently the parser requires all html pages to be well formed or nearly well formed. However in reality many complex pages might contain imperfections which will cause the parser to fail. Therefore, adding fault tolerance capability to the parser will improve its usability. At present the parser handles 5 node types out of 13. The parser can be extended to handle other node types. A larger class library to support development The usability would improve if an extensive class library was available for the framework which would support commonly required work. This could be done by developing a separate class library for PHPlus, or better, by integrating the well reputed PEAR library into PHPlus. Better Tutorials and documentation The acceptance and success of a framework depends a lot on its learning curve. Providing lots of detailed yet simple tutorials and documentation will help the framework to be more usable, thereby, to evolve.

7.2 IDE
The PHPlus editor is already a powerful IDE with functionality such as project management, CVS support and code editing features such as syntax highlighting and method discovery. However more advanced functionality would improve the quality and speed of development. 58

Chapter 7

Future Work

Debugging facility We tried to add this feature, but default debugger was not been able to install as it did not support Red Hat Linux version 9.0. The developer should be to trace through the code execution path and to execute selected portion of the code. More code editing features such as better auto completion, better syntax highlighting, code navigation and syntax checker. Better keyboard shortcut support (with full re-configurability) An integrated web browser window The IDE already has a browser window but it does not support all the HTML tags. As a result of that, it does not render all the documents well. This browser can also be improved to connect to Internet. Simultaneous Multiple project development support Currently, the IDE supports only one project at a time. But in practical situations, the developer may need to refer to several projects frequently. This feature will increase the productivity of such developers. The ability to support plug-ins easily All the functionality for an IDE cannot be provided from the scratch; one needs to incorporate already available free tools to make an IDE more powerful. Integrating a class diagram viewer with the IDE. This class diagram should usually show the attributes and methods in the class, inherited classes and other classes used with the class concerned. The UML should be used for this purpose. More tutorials and documentation on IDE usage At present, the IDE has a reasonably good user guide. We are thinking of adding more content to it as and when we identify topics which will be necessary for the user.

59

Conclusion

Conclusion
Our main aim of doing this project was to make rapid application development possible with PHP without compromising the efficiency for the speed of development. It is with great deal of satisfaction that we say we were able to make this aim a reality, after 6 months hard work. All the development was carried out in Red Hat Linux 9.0 (Kernel 2.4). Working in the latest version of Linux alone is a challenge since bugs are bound to occur and many software upgrades are required to set up the environment. Further, when it comes to development in C++, Linux still lacks a fully-fledged development environment (Method discovery and debugging features are not fully implemented, KDevelop provides some great functionalities and we hope it will address the problems mentioned). The same story goes with PHP. In the same time, there is no other OS that has better support for C++ and PHP than Linux platforms. Our can do attitude helped us to get over all these barriers. This project gave us great insight on developing under Linux environment and interacting with free/open source software community. One of the project decisions we made at the very beginning of the project was to develop the framework in PHP 5 beta version (PHP 5 beta 2). At the time of writing this, PHP 5 is in its beta 2 version (released in November, 2003 and the beta 1 was released in May, 2003). It is still warned that it is experimental and should not be used in production level web sites, yet we decided to use it because the benefits, it offers, out weights the drawback of being experimental. PHP 5 provides a new DOM programming library based on libxml2 (LIBXML2), an XML manipulation library and better support for Object oriented programming through Zend Engine 2 (Zend Engine 2), which are at the heart of our framework. It should be noted that PHP 5 is not backward compatible in the above mentioned areas. We believe PHP developers will release a stable version of PHP 5 in the first quarter of next year (2004) and our framework will be an invaluable tool for web development teams who want speed, quality, manageability and extendibility. We, as a country, have been using open source software readily because of cost benefits, the reliability and acceptance. However, our recognition for contributing to open source by developing software is very little. This can be encouraged in university level and even in secondary school level. We greatly appreciate the work done by Dr. Sanjiva Weerawarana, founder of Lanka (Open Source) Software Foundation, towards this end. We believe our humble effort would also add at least small value in propelling the country to gain recognition in open source software development. IDE was developed extensively using the Qt library for Linux. We believe our IDE would be a great tool for developers who long for painless and faster development. Beyond the technicalities, our 60

Conclusion

team was able to acquire a great deal of domain knowledge in designing user-centered, extensible and powerful IDEs, which is a talent which many software engineers lack of. Because of the time constraints, we had to limit our scope of the project to suit it for 6 months. It is never considered to be a drawback since we, young software engineers, MUST be able to manage time to get at a target, which is realistic, whatever the time period one has. The time to develop is one of the most important resources in any software project. Allocating the time on different task for the group members in order to maximum utilize the development resources is an important and crucial activity in any well managed project. Given the limitations on resources, our team was able to successfully provide the most essential functions and features that a framework and an IDE should have. There are plenty of room to improve the framework and the IDE. The future work section suggests a list of improvements to our project. Both the source code and the documentation are available at http://phplus.sourceforge.net under open source license. We believe this will reach a larger user community, resulting in more constructive feedbacks and criticisms. It is very difficult, if not impossible, to meet all the expectation of every user. However, the software systems can be built to minimize this gap if care is exercised. For any software system to evolve well, constant feedback (suggestions for improvements and bug reporting) should be received by the people who are really using it. This project gave our team members vast amount of experience and exposure in programming on Linux platforms, which is a skill developers lack of. If any one is willing to experience the thrill of success through challenges, Linux is the best platform to work with. It should be noted that once one gets familiar with the platform, it is really productive and efficient. We believe PHPlus fills the need for a framework which separates the design completely from the logic and a free IDE which integrates the framework and ease the task of developers. We hope PHPlus will evolve to be the de-facto platform for the web application development using PHP 5.

61

References

References
Books: BALL, B. and PITTS, D. et al., 1999. Red Hat Linux 6 Unleashed, 1st edn. (Ch. 9, 30, 25) ELMASRI, R. and NAVATHE, S.B., 2000. Fundamentals of Database Systems, 3rd edn. (Ch. 3, 7, 9) KULCHENKO, P., TIDWELL, D., SNELL, J., 2002. Programming Web services with SOAP, 1st edn. (Ch. 1, 2, 3, 5) HERMANS, P. and NORTH, S., 1999. XML in 21 Days, 1st edn. (Ch.1 to 7, 15, 16, 18) PRATA, S., 1998. C++ Primer Plus, 1st edn. (Ch. 12,14,15, 16) PRESSMAN, R.S., 1997, Software Engineering A Practitioners Approach, 4th edn. SOMMERVILLE, I., 2001. Software Engineering, 6th edn. STROUSTRAP, B., 1997. C++ Programming Language, 3rd edn. (Ch. 3, 4, 8, 13, 17)

Important Web Sites/Pages: DOM level 1 spec. - http://www.w3.org/TR/REC-DOM-Level-1/ - Document Object Model Level 1 Specification. Provides details on core DOM and HTML DOM. Last accessed on 15/11/2003

ENHYDRA - http://www.enhydra.org, a web development framework for Java, which extensively uses Java DOM programming. Lasted accessed on 15/11/2003

EOCENE - http://www.eocene.net, a web development framework for PHP, which uses a set of custom defined tags. Last accessed on 15/11/2003 KDevelop, (1998 2003 ) - http://www.kdevelop.org/ a C/C++ IDE for UNIX like platform and publicly available under the GPL. Last accessed on 19/11/2003

LIBXML2 - http://www.xmlsoft.org/intro.html XML C parser and toolkit developed for the Gnome project and it is free software available under the MIT License. Last accessed on 20/11/2003

PEAR - http://pear.php.net/ - Provides many reusable components for PHP and available under PHP license. Last accessed on 22/11/2003

62

References

PEAR::Documentor - http://pear.php.net/package/PhpDocumentor - provides automatic documenting of php API directly from the source. Author - Greg Beaver <http://pear.php.net/user/cellog> Latest version 1.2.3 (released on 13/10/2003) Last accessed on 21/11/2003

PEAR::PHPUNIT - http://pear.php.net/package/PHPUnit - Regression testing framework for unit tests. Author - Sebastian Bergmann < http://pear.php.net/user/sebastian> Latest version 1.0.0 alpha 2 (released on 25/9/2003) Last accessed on 20/11/2003 PEAR::SOAP - http://pear.php.net/package/SOAP - SOAP Client/Server for PHP Authors - Shane Caraveo <http://pear.php.net/user/shane> Arnaud Limbourg <http://pear.php.net/user/arnaud> Latest version 0.8RC2 (released on 17/9/2003) Last accessed on 20/11/2003 PHP ENGINE http://www.php.net home page of the PHP engine which is widely used for web based application development. Online manual, latest PHP version (5.0 beta 2 released in November, 2003) can be downloaded. Last accessed on 20/11/2003

PHPlus - http://phplus.sourceforge.net - open source framework plus IDE for PHP based web application development. The released two the software is available under download section. Last updated on 15/12/2003 Last accessed on 15/12/2003

PHP Usage, Nov 2003 - http://www.php.net/usage.php, survey on PHP usage carried out by NetCraft (http://www.netcraft.com). Last accessed on 15/11/2003

QT - http://www.trolltech.com/download/qt/x11.html - C++ library for developing GUI based applications for UNIX-like platforms. (Windows version is also available) Free Edition is provided under both the Q Public License ("QPL") and the GPL. A free visual designer is available for Qt. Last accessed on 15/11/2003 SOAP Spec 1.1 - http://www.w3.org/TR/SOAP/ - Simple Object Access Protocol version 1.1. Last accessed on 3/11/2003

63

References

XMLWRAPP - http://pmade.org/software/xmlwrapp/ - C++ library for working with XML data. It provides a simple and easy to use interface for the very powerful libxml2 XML parser and the libxslt XSLT engine. Last accessed on 21/11/2003

XML Spec 1.0 - http://www.w3.org/TR/REC-xml Paper describes the XML specification version 1.0 and the second edition. Last accessed on 25/10/2003

Zend Engine2 - http://www.php.net/zend-engine-2.php - PHP engine handles OOP through this module. Last accessed on 22/11/2003

64

Abbreviations

Abbreviations
API CASE CSE CSS CVS DBMS DFD DOM DTD FSF GPL GUI HTML HTTP IDE KDE LSF MDI MVC ODBC OOP SOAP SQL UML URL VB WSDL XML Application Programming Interface Computer Aided Software Engineering tools Computer Science & Engineering Cascading Style Sheets Concurrent Versioning System Database Management System Data Flow Diagram Document Object Model Document Type Definition Free Software Foundation General Public License Graphical User Interface HyperText Markup Language HyperText Transfer Protocol Integrated Development Environment K Desktop Environment Lanka Software Foundation Multiple Document Interface Model-View-Controller Open Database Connectivity Object Oriented Programming Simple Object Access Protocol Structured Query Language Unified Modeling Language Uniform Resource Locator Visual Basic Web Service Description Language eXtensible Markup Language

65

Appendix A

Project Proposal

Appendix A: Project Proposal


Version: 1.0.0 Project title: PHPlus Web Development Framework with PHPlus IDE (open source) Submission Date: 26/5/2003

Authors:
H. S. Gajanayake <hasithag@cse.mrt.ac.lk> M. Y. M. Nabeel <nabeelmy@cse.mrt.ac.lk> M. Y. M. Nasly <naslymym@cse.mrt.ac.lk> S. D. Thilakumara <sampathx@cse.mrt.ac.lk>

Contents
1. Introduction 2. Motivation behind the project 3. Main Modules 4. Technologies and Requirements 5. Require background work 6. Schedule 7. Conclusion 8. References

1. Introduction
Rapid Web Application Development with PHP through our PHPlus framework and IDE

The main objective of this project is to develop a fully object oriented web development framework for PHP where the presentation is clearly separated from the application logic and it incorporates many proven software development practices. In other words, this framework makes the tasks of web designers and web programmers clearly separate, cutting down the development time. Programmers do not need to know about designing and web designers do not need to know about programming. If the design of a site is to be changed in the future, this framework makes the task of the programmer minimal. If the application logic is to be changed in the future, the designer does not have to worry about any thing related to the site. Since no change will be done for the designed HTML pages, future changes to the design can be done without much trouble. The popularity of any framework largely depends on how easy to use it. Behind many successful frameworks, there are development environments. This framework is to be plugged into 66

Appendix A

Project Proposal

PHPlus IDE (an IDE for PHP development, which is to be written in C++ and developed as part of the project. We have identified the need to have a better open source development environment for PHP).

2. Motivation behind the project


At present, a web development framework (Enhydra) for java developers is available. This java framework is used by millions of developers simply because it dramatically increases the throughput. Due to inherent slow responsiveness of java programs, there is a huge requirement from the industry to have an alternative solution for this, which will run faster plus make the web development easier plus theres a real need to separate the logic and the presentation of PHP applications. PHPlus framework is our solution for this problem. (PHP codes run faster than java codes and a similar framework for PHP still has not been built.)

3. Main Modules
PHPlus Framework (core of the project) o This framework separates the presentation from the business logic. Our framework strictly follows the MVC architecture. A parser should be developed to convert the html files into PHP classes and a PHP class library to support this framework. The functionalities to be provided are listed below. Presentation Management This module handles incoming page requests and responsible for initialization process for the first request by any user. As a standard, each html file has a corresponding presentation PHP class and that presentation class may in turn utilize one or more business PHP classes. Database Access Management The user is provided a high-level class library to communicate with external databases. The main advantage of this module is that the user can change the underlying database server with a little or no modification to the existing PHP codes. Session Management Most of the production level web applications require to keep the data across multiple web pages during a user session. This module wraps the session 67

Appendix A

Project Proposal

functionalities that PHP engine provides and the user is provided with an easyto-use interface. DOM manipulation PHPlus framework is based on the DOM of PHP. Each html file is converted to corresponding PHP class where the content of the html file is represented using the DOM of PHP. The DOM manipulation API provides users with a set of very powerful and easy-to-use functionalities to manipulate the DOM during run time. Form Controls This module provides users with a set of methods to manipulate standard form elements such as combo boxes, text boxes, radio buttons and so on. This facility comes in handy especially when one wants to dynamically update a form element during run time. Caching Caching improves the subsequent access to the page. The important parameters are what content should be cached and how long it should be cached. These parameters largely depend on the type of content, amount of traffic to the web site and the resources available in the server.

PHPlus IDE o Facility to manage projects o Code editing features (methods and property discovery, PHP built-in functions, syntax highlighting) o Tools for Testing and debugging o A tool that integrates the Framework to PHPlus IDE. o A tool to assist web services development in PHP o A tool to assist creating documentation

4. Technologies and Requirements


Development Platform : Red Hat Linux 9.0 OOP in PHP (PHP version 5) The current stable version of PHP is 4.3.3. However, PHP group has released an experimental 68

Appendix A

Project Proposal

version 5.0 beta1 this month (May 2003). This version is drastically different form PHP 4.3.x especially in the area of DOM manipulation. It provides more supports for object oriented programming through the Zend engine2. With the know risks, our team decided to use the PHP 5.0 beta1 version (which does not have a documentation of its own) since at the heart of our framework is DOM manipulation and the framework is completely object oriented. This is in fact inline with one of our objectives that software solution should not be out-dated by the time it is released. C++ for the parser of the framework C++ Qt library for the development of PHPlus IDE. UML for analysis and design Web services (Java Axis, PEAR::SOAP) DOM parsing (C++ and PHP)

Software requirements: Red Hat Linux 9.0 (kernel version 2.4) (open source) PostgreSQL database server, KDevelop environment, Qt designer, Apache web server and gcc utilities. Argo UML (open source) Apache Axis (open source) J2SDK for Linux (freely available) Apache Tomcat version 4.0 (open source) CVS client and server (open source) PHP 5 beta1 (open source) PEAR libraries (open source) Hardware requirements: Intel Pentium III/AMD with 1.5 GHz (or Higher) Internet connection

5. Required Background work


Studying the existing java web development framework (Enhydra) 1. Jakarta Struts2 Studying the existing PHP frameworks (Eocene3, PHP2Go, Blueshoes), which have their own drawbacks, but may be useful to understand how a framework works. 69

Appendix A

Project Proposal

Studying the Qt4 development environment and GUI design on Linux. DOM parsing techniques Knowledge on UML diagram designing Studying the PEAR5 SOAP and NuSOAP libraries for incorporating web services.

6. Schedule

We hope to deliver the first increment in mid-August, 2003 and the second (final) increment in mid-November, 2003.

7. Conclusion
Our main aim in selecting this project is to make the web development using PHP fast and painless through the proven software development techniques, without compromising the run time speed (i.e. the efficiency). Further, this makes web development team, which consists of designers and programmers, function efficiently, undoubted resulting in higher throughput. We intend to make this an Open Source Project.

8. References
1 http://www.enhydra.org Last accessed : 23/5/2003 An open source web development framework for Java

2 http://jakarta.apache.org/struts/ Last accessed : 24/5/2003 An open source framework for java web application development 70

Appendix A

Project Proposal

3 http://www.eocene.net Last accessed : 23/5/2003 Author : Deepak Dutta An open source web development framework for PHP 4.3 and uses a set of custom defined templates

4 http://www.trolltech.com/products/qt/ Last accessed : 24/5/2003 A multiplatform, C++ application development framework

5 http://pear.php.net/packages.php Last accessed : 24/5/2003 Open source packages for PHP to support web services, documentation, and so on.

http://www.php.net Last accessed : 26/5/2003 Official web site of PHP engine. The latest stable version is PHP 4.3.3, but an experimental version 5.0beta1 was released in May 2003.

71

Appendix B

Feasibility Report

Appendix B: Feasibility Report


This report investigates the possibility of carrying out the PHPlus project, which consist of object oriented web development framework and an IDE for PHP.

Analysis and Assessment


1. Does the project fall within the direct objectives of the department of CSE? Our investigation on the previous final year project revealed that there were no projects carried out to provide CASE/case to PHP programming language. The department encourages doing innovative and research based projects. It is a plus point that this project combines the power, efficiency and complexity of C++ (which requires higher degree patience and competence), ease of use of Java (which reduces the development time at the cost of performance) and efficient and excellent set of functionality of PHP. This project is to use the latest version of Red Hat Linux (version 9) and latest version of PHP engine (version 5 beta1) which requires a research based approach to development.

2. How is the project useful for PHP community working mostly on Linux platform? With our survey and industry experience, it was found that most of the PHP related applications were developed in Linux platforms. At present, there is no better way to separate the design and the PHP code. So, there will be a good response from the people who involve in large to medium scale project based on PHP for a framework which does separate the above two aspects. Without such a framework, developers at present find it difficult to maintain web sites and collaborate with web designers. Zend Technologies (ZEND) provides a commercial IDE for PHP and theres a free somewhat good IDE (as mentioned in the feature list of their site), called PHPMole (PHPMOLE), but it is difficult (if not impossible) to install in Linux OS. Due to the above shortcoming, an IDE for PHP, which is free, provides good features and is easy to install, would be a great tool for PHP developers.

3. Does the project go inline with our direct objectives? What direct contributions does it make? This project embarks on building CASE/case tools rather than building custom software which satisfies the need of a limited group of people. It is found that many organizations reap the benefits of the Enhydra (ENHYDRA) framework, which is based on java and separates the design and the logic, in web based development but the problem with this is that the inherent slowness of JVM makes the whole web application slow. Industry is exploring the possibility of migrating to efficient plus faster

72

Appendix B

Feasibility Report

web development technologies. This will invariably be a great tool for those who want speed and quality.

4. Does the project require new technologies which our project team has never used before? During our initial studies, the new technologies, which are Qt programming, C++ DOM programming, C++ programming in Linux and PHP DOM programming, can be mastered in the estimated time period for learning the new technologies. Our project team has fairly good experience with C++, PHP and Web Services using SOAP, it was found that these technologies can be mastered as the development is being carried out.

5. Can this project be finished on schedule while the academic work is being carried out? A final year project should be large enough to create an impression and small enough to be finished in 6 months time. As the first step of time management, the modules and functionality to be provided were decided on. Scheduling of these activities, paying due consideration for unexpected risk, revealed that the identified functionality can be carried out in 5 to 5 months. To be in the safe side, it was decided not to allocate the last months time. 6. Can the project be done using the identified technologies in Linux? Through our experience, it was well known fact that there is no other operating system that provides better support for C++ than Linux. The project team was conscious of incorporating technologies which already had wide acceptance or are becoming popular among developers. So, this approach made certain that the project can be done in Linux alone.

7. Can the whole project be done using free software only? As this project is open source, it cannot incorporate third party libraries and software. Through our initial research on the technologies it is certain that identified functionalities can be implemented in either open source or free software. In fact, to provide some functionalities, there are more than one alternative.

8. Are there any similar projects? Can our project be unique for PHP? During our investigation period, we were able to find a free framework written for PHP called Eocene (EOCENE). The main drawbacks of it were;

73

Appendix B

Feasibility Report

It uses custom tags to incorporate dynamic content in HTML page as it is not an industry standard there is little acceptance for it. Further, this approach makes future modification to static HTML pages difficult and time consuming as it cannot be done using a designing tool. It is designed to work with PHP 4.3 and does not work with PHP 5. The user is not given the ability to extend the framework. The analysis on this helped us to perform a good requirement analysis on PHPlus framework. There is no doubt that the framework the project is going to develop is unique and the IDE will also be unique in the sense it will be developed using Qt library, will be easy to install in Linux, will be free to use, will incorporate the framework, will provide facility to cater for current trends (e.g.: web services) and will encourage good programming practices.

9. How can we acquire knowledge from similar projects done for languages other than PHP? The motivation for the framework came from a java based framework for web application development, Enhydra, and our project team had experience with this framework plus PHP without a framework. It was decided to concentrate on the plus points of the java based framework and how to provide a similar framework for PHP which is more efficient and robust.

10. Can the identified technologies be put into work within a month's time from the inception? As initial study is crucial to the success of the project, considerable amount of time is allocated to study the new technologies. Once the technologies are mastered, it takes relatively less time to develop. To expedite the learning process it was suggested to share the knowledge among the group members each one concentrating on particular technologies or particular parts of the technologies.

11. Can the project be fit into an existing process model, which consists of a set of activities to come up with the solution? Complexity of software projects stems from the fact each one is unique in some respect. A conscious effort is made to follow a standard process model since duration of the project is relatively short there is no time to device a process model for the purpose. It was found that the project can be done with a combination of incremental and spiral model.

12. Can this project be convinced that it is innovative and makes most out of the software engineering concepts?

74

Appendix B

Feasibility Report

With our thorough investigation, it is confident that no one has built a framework for PHP based on the PHP DOM programming to the date. As most of the programming is done with C++ and PHP, (it is a well known fact that it requires a great deal of capacity and competence) challenging nature of the project should be clear to any one who has been in this field. One has to specifically consider factors such as quality, extendibility, reliability and efficiency when building a framework which is to be used as the foundation of many applications. The above factors decide the overall performance the application built on top of the framework irrespective of how well the custom software is developed. Further the IDE, which is to be used in the development of any PHP project, should be reliable, user-friendly and encourage developers to follow good programming practices as well. It should be clear that without proven software engineering techniques, those factors cannot be made a reality.

Conclusion
This project is inline with the objectives of the department of CSE and the objectives of the project team. It will truly add a value to PHP based web application development and it will be a very vital tool(s) for the industry and PHP community at large, to perform collaborative rapid team work. It is recommended that the project is continued.

References
ENHYDRA - http://www.enhydra.org, a web development framework for Java, which extensively uses Java DOM programming. Lasted accessed on 15/5/2003 EOCENE - http://www.eocene.net, a web development framework for PHP, which uses a set of custom defined tags. Last accessed on 15/5/2003 PHP ENGINE http://www.php.net home page of the PHP engine which is widely used for web based application development. Online manual, latest PHP version (5.0 beta 12 released in May, 2003) can be downloaded. Last accessed on 20/5/2003 PHPMOLE - http://www.akbkhome.com/Projects/Phpmole-IDE/?click=1070365869 An IDE for PHP developed using PHPGTK. Last Accessed on 15/5/2003 ZEND - http://www.zend.com/store/products/zend-studio.php - Commercial IDE for PHP developed by Zend Technologies. Last Accessed on 13/5/2003

75

Appendix C

Risk Management Report

Appendix C: Risk Management Report


Risk Identification and Analysis Note: Project risks affect either the project schedule or the resources. Project risks affect either the quality or the performance of the software being developed. Probabilities are assessed as five fuzzy levels; very low, low, moderate, high and very high. Similarly, the seriousness of a risk is ranked into four levels; catastrophic, serious, tolerable and insignificant. Risk There will be changes to the requirements than anticipated. Dependent modules are not available on schedule. The size of the project has been underestimated. The development environments (KDevelop and Qt designer) do not perform as anticipated. XMLWrapp, the free library used for XML manipulation in C++ has more bugs and less functionality than expected. PHP 5 beta is unstable for the development of the framework on top of it. Hardware which is essential for the project will not be available on schedule. All the software support required will not be available with the Red Hat Linux 9.0 (latest version to the date). The time required to develop the software is underestimated. Key project members are ill and unavailable at critical times. Lack of documentation for PHP 5, KDevelop will cause problems during development and will require more time to develop than anticipated. It will be difficult to find a project supervisor who has a good knowledge on the area that our software is built. It will take more time to study about Qt and C++ 76 both high tolerable project low tolerable both high serious both low serious project moderate tolerable project moderate tolerable project low serious both moderate serious both moderate serious Risk Type both project project project Probability moderate low moderate moderate Effects serious serious tolerable tolerable

Appendix C

Risk Management Report

programming in Linux than expected. There is a chance of closing down the university for some reason and it will not be possible to carry out the project in the lab. There will be lack of resources at critical times of the project. Academic work/pressure will affect the project more than expected. Research based framework development will take more time than estimated. Internet will not be available at critical times when mailing lists and expert ideas are invaluable. The project will not be coordinated as expected. The requirements will not be understood by all the members in the same way as expected. Performance of the PHP 5 engine is not so good as anticipated. There will be more memory leaks and segmentation faults when developing the IDE than expected. Documentation of code done by each project member is not consistent. Documentation of code is not sufficient. Coding standards used are not consistent among group members. Open source Pear libraries (SOAP, PHPUnit and PHPDocumentor) will not directly work with PHP 5. Installation of PHP 5 beta versions will require other software in Red Hat Linux to be upgraded. project very high tolerable both high tolerable product product low moderate tolerable tolerable product moderate tolerable product moderate serious product low serious project product low moderate serious serious both low serious both moderate tolerable both low tolerable project low insignificant project low serious

Risk Planning The key risks are highlighted in the above table and following strategies are identified to manage with them. Risk: There will be changes to the requirements than anticipated. 77

Appendix C

Risk Management Report

Strategy: More time should be spent on to separate out categorize the requirements into stable and notso-stable. First increment should be developed with the most stable set of requirements. We must maximize the information hiding in the design.

Risk: XMLWrapp, the free library used for XML manipulation in C++ has more bugs and less functionality than expected. Strategy: XMLWrapp is simple and provides the basic functionality. If few functions are not found we may write our own function to complement the need. If it gives serious bugs and problems, we may shift to the alternative XML library Xcerce-C++, which is very powerful but a bit complicated.

Risk: PHP 5 beta is unstable for the development of the framework on top of it. Strategy: We must pay more attention to PHP 5 mailing lists and news groups to get the experience of the user and avoid pitfalls in PHP 5. If a function does not work as expected, we may have to perform that using other working functions.

Risk: Lack of documentation for PHP 5, KDevelop will cause problems during development and will require more time to develop than anticipated. Strategy: Even though theres no official documentation for PHP 5, we may search for the possibility of other documents produced by various people. It is very import to have a good understanding of the changes made to PHP 5 so that we may continue to use the excellent documentation available for PHP 4.3. Register with mailing list for PHP and KDevelop to obtain the latest news.

Risk: The requirements will not be understood by all the members in the same way as expected. Strategy: Constant review should be held on the progress and to discuss requirements and implementation among group members. Whenever possible, at least a block diagram should be drawn to better understand the requirements.

Risk: There will be more memory leaks and segmentation faults when developing the IDE than expected. Strategy: An error log should be maintained to list the ways in which these errors occurred so that the same mistake may not be done once again. A thorough knowledge on the Qt programming is essential (it is worth spending a bit long time on the initial learning stage) to avoid many mistakes.

78

Appendix D

Requirements Document

Appendix D: Requirements Document


This document describes the final outcome of the requirements engineering on the final year project PHPlus. PHPlus consists of two main modules; the framework and the IDE. PHPlus framework introduces a mechanism to separate out the design and the business logic of web pages. PHPlus IDE is a fully-fledged IDE for PHP web application development for Linux.

Contents
1. User Requirements Definition 2. System Requirements Specification 3. System Models Note: Throughout this document, mandatory requirements are defined using shall and desirable using should.

1. User Requirements Definition


1. Framework 1.1 Parser Description: One of the two main components of the framework which convert HTML files into PHP classes. 1.1.1 Parser shall convert one or more than one well-formed HTML files into a PHP DOM class(es). Description: Well-formed HTML file is a file that follows the basic XML syntax rules. Each tag should have either an ending tag or a self ending tag. e.g.: <H1>welcome</H> <BR/> There should not be any special characters (e.g.: & ;) in the HTML file. Tag names should follow the standard naming conventions. PHP class produced shall work with PHP version 5. Rationale: Converting the HTML file into PHP DOM provides a very high flexibility to the user to incorporate dynamic content and these classes can easily be extended to provide more functionality to the user. User is allowed convert any number of files at the same time 79

Appendix D

Requirements Document

as in real life situation usually programmer needs to convert a set of related static HTML files that the designer makes available. 1.1.2 Parser shall handle HTML files which are not well-formed. Description: Parser shall be able to handle the following situations. 1.1.2.1 Parser shall be able to add self-ending tags, if necessary. 1.1.2.2 Parser shall comment code inside the inline scripts including java scripts and VB scripts. 1.1.2.3 Parser shall encode special characters in the file. (Ampersand, semi-colon) Rationale: Most web designing tools, available at present, produce HTML files very close to XML syntax rules. In order to manipulate the HTML file in should be 100% follow the HTML syntax. 1.1.3 Parser shall add methods to PHP classes to manipulate the DOM of those classes. Description: PHP DOM class generated by the parser should be manipulated using PHP DOM programming to incorporate dynamic contents. Rationale: Manipulation of the DOM requires considerable amount of coding. User is shielded from this complexity and provided with a high-level API for this purpose. This reduces the development time. 1.2 Class Library Description: It must contain PHP classes to handle the framework activities. In addition to providing functionality to manipulate the DOM, it shall contain functionality to providing caching, database handling, XML manipulation and HTML form component handling. 1.2.1 Presentation Management Description: All the PHP page requests are sent to this module and it should handle the underlying complexity of creating the HTML file from the presentation, resource and business PHP classes. If the requested page is not found, an error message shall be displayed. 1.2.2. Cache Management Description: To improve the response time for the subsequent request for the same page, caching should be implemented. Complex calculations shall also be cached.

80

Appendix D

Requirements Document

1.2.3 Database Management Description: User shall be provided a high-level API to connect to databases. The user shall be able to change the database without changing the code written to access and manipulate database. 1.2.4 DOM manipulation API Description: User shall be provided with an easy-to-use set of functions to manipulate the DOM of the parser generated classes. Rationale: Shield the user from underlying complexity of doing DOM programming in PHP and improve the productivity of the user. 1.2.5 XML Control Description: User shall be provided an API to manipulate (load, edit, create) XML files. Rationale: XML is becoming the de-facto standard of exchanging data. It is a very frequent activity of working with XML files during web based application development. So, through this, user is prevented from performing the same activity repeatedly. 1.2.6 Web Form Control Description: User shall be provided with an API to manipulate FORM tags in an HTML file. Rationale: In many practical situations, values of the FORM tags should be set dynamically. This is usually done using either java scripts or VB scripts. These scripts not only causes inter-operability problems but also the programmer needs to master writing scripts.

2. IDE (Integrated Development Environment) Description: IDE should provide the functionalities found in popular IDEs. It shall follow the work style of major Linux IDEs such as KDevelop and Qt designer. It shall integrate the framework developed as part of the project. Rationale: Any useful IDE should be user-centered. In other words, it should be user friendly. By following the standards of popular IDEs, a greater user acceptance of the IDE can be achieved. IDE together with the framework will definitely speed up the web development activity. IDE shall provide MDI environment User shall be able to access any of the loaded files through a tab bar IDE shall provide project management facilities User shall be able to create a new project from the scratch 81

Appendix D

Requirements Document

User shall be able to create a new framework project There shall be facility to create a project from an existing set of files and folders Folders and files structure of the base directory shall be shown in the IDE using a tree view. User shall be able add new files and delete existing files from the tree. User shall be able to rename a file User shall be able to open HTML files either in limited built-in browser or in a existing web browser The tree structure shall show any type of file. When the user double clicks on a file, it shall be open in an editor window. When a new file is added from the menu or toolbar, the tree shall be updated accordingly. When a file is added from the outside of the IDE to the project, the tree shall update itself automatically. The IDE shall keep track of the recently opened projects. The IDE shall provide menu bar option, toolbar option and shortcut key option to save one or more than one file at any time. The IDE shall provide code editing facilities. Editor window shall be able to load either HTML or PHP files Editor window shall provide syntax highlighting for PHP and HTML files. Two syntax highlighting schemes shall be used separately and based on the file extension highlighting shall be performed. Files with extension other than .php and .html should be kept without highlighted. Syntax highlighting shall activate once a file is saved if it is built from the scratch. The editor shall provide method discovery facility. When the user type an arrow, all the possible methods and attributes shall be shown. User shall be able to see the methods in the included files. User shall be able to see the methods in any file in the PHPlus class library. User shall be able to see the methods in the parent class. The editor shall provide auto completion for variable names, class names and standard PHP functions The source as well as the browser output shall be seen for any HTML file. The browser shall be able to parse standard HTML tags, render images, render form controls and render CSS styles. IDE shall provide the facility to set user preferences. 82

Appendix D

Requirements Document

User shall be able to set font type, size and word wrap through a dialog box. IDE shall provide a graphical tool to work with CVS. CVS tool shall show the files in a tree view. Status of each file shall be shown in the tree itself. User shall be able to perform common CVS functionalities graphically. IDE shall provide a tool to use the XMLCPlus parser. User shall be able select the files to be parsed. User shall be able to select the output folder. User shall be able to configure the IDE so that the parser location can be specified. Tool shall display the output of the parsing activity. Tool shall update the project tree accordingly. IDE shall provide a tool to deploy the current project. User shall be able to select the files and folders to be deployed. User shall be provided the facility to select the web server which may reside in the same machine or a different machine. Tool shall display the output of deployment activity. IDE shall provide a tool to generate SOAP clients. The tool should provide a dialog box to get the location of the WSDL file and the output directory. Tool shall display the output of this activity. Tool shall update the project and class trees accordingly. IDE shall provide a tool to generate skeletons of Unit test cases. User shall be provided the facility to either generate one or more unit test cases. IDE shall provide a tool to generate javadoc like documentation for the PHP code IDE shall show the class structure and the methods and properties in each class in a tree view. When the user double clicks on any item in this tree, IDE shall move the cursor to the relevant location. User should be provided facility to add methods and attributes using this tree view. IDE shall provide a help system. Each dialog box shall have a help built into it. Help content shall contain each component of the IDE. Help system shall provide improved access to PHP documentation.

2. System Requirements Specification


83

Appendix D

Requirements Document

2. Framework 1.3 Parser Description: One of the two main components of the framework which convert HTML files into PHP classes. Parser shall be implemented in C++. To manipulate the DOM of the HTML file, a third party library, XMLWrapp, is to be used. 1.3.1 Parser shall convert one or more than one well-formed HTML files into a PHP DOM classes. Description: Well-formed HTML file is a file that follows the basic XML syntax rules. Each tag should have either an ending tag or a self ending tag.
e.g.: <H1>welcome</H> <BR/>

There should not be any special characters (e.g.: & ;) in the HTML file. Tag names should follow the standard naming conventions. XML manipulation functions in PHP 5 are completely different from those in PHP 4.3, which is the current stable version. It is decided to use the functionalities in PHP 5 in keeping with our objectives. PHP class produced should be in PHP version 5 and is completely object oriented. DOM shall be written in the constructor of the class itself. The name of the PHP class shall be as same name as the HTML file, except the first letter shall be made capital and the word HTML shall be appended to the end of the name. e.g.: HTML file is test.htm, then the PHP class name would be TestHTML and the file name TestHTML.php Rationale: Converting the HTML file into PHP DOM provides a very high flexibility to the user to incorporate dynamic content and these classes can easily be extended to provide more functionality to the user. User is allowed convert any number of files at the same time as in real life situation usually programmer needs to convert a set of related static HTML files that the designer makes available. Manipulation of the DOM to change the content is an industry standard. An Experienced programmer can directly manipulate the DOM, so it provides a great degree of flexibility to users. 1.3.2 Parser shall handle HTML files which are not well-formed. Description: Parser shall be able to handle the following situations. 1.3.2.1 Parser shall be able to add self-ending tags, if necessary. 84

Appendix D

Requirements Document

Description: Tags to which self ending tags are to be inserted shall be written to a separate file called tags.txt. Each line of this file contains one tag. Sample file data is shown below.
META LINK INPUT BR HR IMG

Parser checks for these tags in the HTML before creating the C++ DOM and adds a / proceeding the closing tag if it is not found. Rationale: The tag list is kept in a separate text file in order to provide the user to add new tags, as and when it is found, without recompiling the program. 1.3.2.2 Parser shall comment code inside the inline scripts including java scripts and VB scripts. Description: As the scripts may contain special characters, inline scripts in the HTML file must be commented by the parser before the XML tree is built. An example, where the parser has commented the code inside the java script, is shown below.
<script language=javascript> <!-if (age > 40){ message = you are old; } --> </script>

1.3.2.3 Parser shall encode special characters in the file. (Ampersand, semi-colon and comparison operators) Description: One cannot create the XML tree if there are special characters inside the text nodes or attribute names and values. The special tags are encoded by the parser and these encoded patterns are removed by the framework class library. Rationale: Most web designing tools, available at present, produce HTML files very close to XML syntax rules. In order to manipulate the HTML file in should be 100% follow the HTML syntax. 1.3.3 Parser shall add methods to PHP classes to manipulate the DOM of those classes. Description: PHP DOM class generated by the parser should be manipulated using PHP DOM programming to incorporate dynamic contents. If there is an ID in SPAN, A or FORM tag, a method based on the tag shall be provided to incorporate dynamic contents. For a SPAN tag, set text method is added, for a A tag, set hyperlink method and for 85

Appendix D

Requirements Document

FORM, set form action. In addition to this, each PHP class must extend the DomHTML class, which contains methods to manipulate XML documents. All the other tags which contain IDs shall be added to the node list. Rationale: Manipulation of the DOM (e.g.: populate a table) requires considerable amount of coding. User is shielded from this complexity and provided with a high-level API for this purpose. This reduces the development time. 1.3.4 When there are radio buttons in the Form, each radio node shall be added to a two dimensional array. Description: Since radio button work as a group, it is difficult to identify the group to which a radio button belongs simply by looking at the ID value. These radio nodes shall be separately handled.
e.g.: in the HTML file => <input type="radio" name="gender" value="male"> <input type="radio" name="gender" value="female"> <input type="radio" name="gender"> DOM output should be (sample) => $this->radioNodes["gender"]["male"] = $node3; $this->radioNodes["gender"]["female"] = $node3; $this->radioNodes["gender"][] = $node3; (Here $node3 is a pointer to each radio node; since they are in the same level in the DOM tree they should get the same name)

1.4 Class Library Description: It must contain PHP classes to handle the framework activities. In addition to providing functionality to manipulate the DOM, it shall contain functionality to providing caching, database handling, XML manipulation and HTML form component handling. 1.4.1 Presentation Management Description: All the PHP page requests are sent to this module and it should handle the underlying complexity of creating the HTML file from the presentation, resource and business PHP classes. If the requested page is not found, an error message shall be displayed. As a usual practice, all the parser generated PHP classes should be placed in a directory called resources (example file name would be WelcomeHTML.php). For each of these classes, a presentation class should be created to display the content and manipulate the content. (e.g.: WelcomePresntation class should create an object of WelcomeHTML class, and may use its methods to manipulate the DOM) The presentation classes shall be placed in a directory called presentations (example file name would be WelcomePresentation.php). All the page requests shall come in the form of GET requests to a single page. (e.g.: if that single page is Receiver.php, the page request would be Receiver.php?page=Welcome) 86

Appendix D

Requirements Document

1.4.2. Cache Management Overview: Cache Management facility in PHPlus will enable the user to cache application components. The components could be complete web pages, parts of pages such as tables, or results of some complex business calculations. Serving components from the cache rather than dynamically generating them will be significantly faster. Rationale: Most dynamic components used within a web application might not change within a given period of time. The time required to re-generate these components can be significantly reduced, if they are cached; For example, the content of a web page table populated with an XML file or a database might change only once or twice per day. If we cache these contents with a life time of a day, the actual data will need to be read only twice a day; all other requests would be catered from the cache, which is extremely fast, hence improving the responsiveness of the application. Implementation: Cache Management will be handled by a separate Cache Manager class. This class will provide methods for the caching of complete web pages, parts of pages such as tables, and calculation results. The cached items will be saved in temporary files in the systems temporary folder. Cached items will have a unique identifier key and a lifetime (specified by the user, at the time of caching). When generating a web page the user will be able to check if the item is already cached, and whether its valid (not expired), and if so, to use it directly. If the component is not in the cache or expired, the user can re-cache it with new data, by specifying a unique key and a lifetime. Expired items will be deleted from the cache. Partial page

components such as tables will be added to any node in the DOM tree of the HTML page, simply by specifying the node ID. All complexities of actually appending it to the DOM will be transparent to the user. Limitations & constraints: Custom object caching will not be supported due to time constraints. The cached items will not be encrypted due to performance considerations. 1.4.3 Database Management Overview: Database Management facility will enable the user to use a simple, unified, intuitive interface to use ODBC databases and SQLite database, and to use the result sets to easily populate dynamic web pages. Implementation: Database Management will be handled by a separate module having several classes. The interface will be simple and intuitive, and will be common for both SQLite and ODBC. The result sets returned from database queries will be easy to use (designed in a manner

87

Appendix D

Requirements Document

similar to MS DAO). The framework will have wrapper methods to directly use these Result Sets for dynamic table population on web pages, and will provide a great deal of flexibility. Limitations & Constraints: Advanced database manipulation functionality such as persistent connection handling will not be provided due time constraints. 1.4.4 DOM HTML Controller (DomHTML) Overview: This is the core of the PHPlus framework. The DOM manipulation facilities will enable the user to quickly and easily manipulate dynamic components of a template html page programmatically, separating the web interface design and the application logic completely and cleanly. It will also include many wrapper methods to support XML, databases, web services, web form controls etc. The complexity of manipulating the DOM will be transparent to the user. Rationale: The user can manipulate the template HTML file by the manipulation of its DOM tree. Using native bare-bone DOM manipulation methods provided by PHP is too complex and tedious work, requiring a great deal of DOM knowledge. Therefore a simple, intuitive yet powerful interface is required to efficiently manipulate the template HTML file. This will be provided by DOM HTML Controller. Implementation: DOM HTML Controller will be implemented separately in a DomHTML class. It will provide a large number of methods for manipulating a DOM tree, specifically in the context of HTML. The methods will range from very low level methods to very high level methods for HTML tag manipulation. They will include HTML specific manipulations such as web form table population, list box populations and radio button manipulation. The HTML terminology will be used as much as possible in these methods rather than the generic DOM terminology. Limitations & Constraints: constraints. exception handling will not be implemented due to time

88

Appendix D

Requirements Document

1.4.5 XML Control Description: User shall be provided an API to manipulate (load, edit, create) XML files. Rationale: XML is becoming the de-facto standard of exchanging data. It is a very frequent activity of working with XML files during web based application development. So, through this, user is prevented from performing the same activity repeatedly. 1.4.6 Web Form Controls Overview: web form wrapper will enable the user to easily manipulate web form controls, which would else be very tedious work. Rationale: web form controls are commonly used in todays web applications. The solutions available currently for dynamically manipulating these controls (such as java script) are not satisfactory in terms of flexibility and maintainability. Therefore a better approach is required for the dynamic manipulation of web controls. Implementation: The web form control wrapper will be implemented in a separate section in the DomHTML class. These wrapper methods will be capable of handling all web form controls such as textboxes, text areas, list boxes, checkboxes, hidden fields and radio buttons. The facilities included will be status changes of existing controls, dynamic addition of new controls and dynamic population of data.

89

Appendix D

Requirements Document

3. System Models
The context model, which relates the system under consideration with the out side world, of the framework is shown below.

Session Manager Web Server

Cache Manager

Configuration Manager

Presentation Manager + Controller Database Manager

Cached data Conversion System + DOM manipulator

Config data

DB storage

PHP DOM files

Fig 1 Context model of the PHPlus framework

90

Appendix D

Requirements Document

The following diagram illustrates the dataflow in the framework.

Session Manager Page Request

Generated PHP DOM classes

Receiver

Controller + DOM manipulator

HTML Generator

HTML file

Config Manager

Database Manager

User Classes (business & presentation)

Config Data

DB Data

Cache Manager

Cached Data

Fig 2 Data Flow Diagram for Request Processing

91

Appendix D

Requirements Document

The following diagram illustrates the main modules, which shall present in the PHPlus IDE.

Configurator

CVS Client

Project Manager

XMLCPlus Parser Documenter

Main Application Window

Text Editor Syntax Highlighter

Unit Test Gen. Wizards Deployer SOAP Client Tool DB Connector Class Parser Static Parser Dynamic Parser

Fig 4 Modular view of PHPlus IDE

92

You might also like