Implementing Singleton method in Design of MVCBased PHP Framework
- 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