Implementing Singleton method in Design of MVCBased PHP Framework

PHP provides a framework that aims to accelerate the process of developing a website. Today, there are many object oriented programming based framework that uses full-stack model design to MVC (Model View Controller) design. The use of these designs, especially MVC design, is to provide ease in web application development. Writing the code is becoming more systematic and reusable. In addition, the use of framework greatly helps programmers in the development of large-scale applications that involve a lot of people in it. With the framework, the code will be organized so that it can be easily understood by other programmers. There are many choices of use framework. Among them, there is Zend framework which is devoted to enterprise scale. However, this framework is rarely used because it is less popular compared with CodeIgniter and Yii framework. CodeIgniter is quite mild and can run faster than other frameworks. But the drawback is the absence of features ORM (Object Relational Mapping), so that it becomes more complicated when used in large applications. While the Yii framework has better features than CodeIgniter, but slower performance than CodeIgniter. To overcome the disadvantages of the 2 framework, it is built a new framework namely Becak HMVC.1) This framework is designed to simplify the design pattern and minimize the number of files. From the test results, it was found that the framework Pedicab HMVC have drawbacks such as the lack of library cache (temporary storage) and AJAX (Asynchronous JavaScript and XML). As a result, the performance of this framework is still not maximal.2) This research aims to produce a new framework that it’s performance more efficient than Yii framework, has ORM and AJAX feature. This is done by simplifying the design pattern and minimizing the number of files. In addition, it also uses a new way that found on PHP 5.3, namely the use of namespace (package) with the Singleton pattern (initialization once in the manufacture of objects).

  1. System Design Hierarchy structure of framework that was built looks like in Figure 1. This structure will be the basis or framework, which will serve as a folder or directory. After that, it will set up the structure of the namespace of the class that will be built. The main component of this framework is the core part. This section contains the basic classes that will handle the routing of the url. In addition, there is also a class to set the commonly used objects or to save the instance of the class that will be stored in the class registry. With the registry, no needs to create an instance manually. In the sub-system, there is also a class Exception to do error handling. The error that can be handled is a runtime error and a database error. Another component is the db namespace that is used to perform database operations. This adapter is used to handle multiple database connection. This database is called only from a factory method, so it will be easier for developers to create applications from various databases.3) There is also a wide variety of adapters that can be used to perform database operations such as mysql, mysqli, oci8, and pgsql driver. Driver is a native of the extension php and include primitive enough for this type of connection. For the more modern connection, php provides PDO connection. PDO extension provides many types of drivers to connect to multiple types of databases including MySQL, Oracle, SQLite, and PgSQL. In terms of security, the connection with the PDO is considered more secure, because all input will be filtered first by performing variable bindings before doing the query to the database.4) To speed up the processing time, there are features to do caching on web pages or data derived from the database. This feature is useful to accelerate the performance of a website, which is measured by the speed of processing a web page. How it works caching is to store data temporarily in files or cache engines such as memcache, apc, or alternatively phpcaching. B. Framework Architecture Based on the design of the hierarchy structure of folders or namespace that has been made, the UML design was made. UML package diagrams that exist in figure 2 illustrate the architecture of the framework to be created. The main system will apply the Singleton design pattern. There is only one class that will be used as a superclass. To call a sub-system, it is used design pattern facade. As for subsystems such as the database, will be used design pattern adapter. For helper subsystem, there are classes such as paging, captcha, sessions, cookies, etc.

RESULT AND ANALYSIS

In this section, will be presented the results of comparison tests between the new framework created in this research, compared with Yii and CodeIgniter framework. Benchmarking will be carried out on aspects of features, throughput static and dynamic pages, computing time in static and dynamic pages and memory resource usage .

Comparison of Framework Features There are some features that will be compared between the new framework created in this research, compared with the features of CodeIgniter and Yii framework. Here is a list of the standard features of a framework: • MVC: Model View Controller supports • Multiple DB’s: supports multiple databases without changing the code. • ORM: supports object relational mapping, sometimes implementation is active record. • DB Objects: support for object database • Templates: there is a template engine • Caching: support caching to a website • Validation: support input validation and filtering • Ajax: AJAX support by default • Auth Module: supports modules for login and access control. • Modules: support for other modules such as RSS, PDF Parse • EDP: Event Driven Programming

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>