0% found this document useful (0 votes)
58 views12 pages

Olanrewaju 2015

This chapter summarizes an empirical study on the evolution of PHP MVC frameworks. It discusses popular PHP MVC frameworks like Laravel, Symfony, CodeIgniter and CakePHP. The study evaluates the performance of these frameworks and finds that Laravel outperforms the others. The chapter thus proposes Laravel as the most suitable PHP framework for future web development projects.

Uploaded by

yousef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views12 pages

Olanrewaju 2015

This chapter summarizes an empirical study on the evolution of PHP MVC frameworks. It discusses popular PHP MVC frameworks like Laravel, Symfony, CodeIgniter and CakePHP. The study evaluates the performance of these frameworks and finds that Laravel outperforms the others. The chapter thus proposes Laravel as the most suitable PHP framework for future web development projects.

Uploaded by

yousef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Chapter 40

An Empirical Study of the Evolution


of PHP MVC Framework

Rashidah F. Olanrewaju, Thouhedul Islam and N. Ali

Abstract Commercial, social and educational importance of web technology has


tremendously increased research activities in web programming/scripting. Several
methods for writing PHP codes such as Object Oriented Programming (OOP),
Procedural PHP coding and Model View Controller (MVC) pattern have been
proposed. Model View Controller (MVC) which is one of the most powerful
method for developing PHP application has many variant such Laravel, Symfony,
CodeIgniter, CakePHP etc. However, selection of best MVC framework among
the variants is of concern to the programmers as well as project managers, espe-
cially when managing big applications. Hence, performance evaluation criterions
are required. This paper discusses the MVC based most famous PHP frameworks,
evaluate their performance and it was found that Laravel outperforms other MVC
framework, hence Laravel is proposed as the most suitable PHP framework for
future web technology.

Keywords MVC  Laravel  PHP framework  CakePHP  CodeIgniter 


Symfony

R.F. Olanrewaju (&)  T. Islam


Department of Electrical and Computer, Kulliyyah of Engineering, International Islamic
University Malaysia, P.O. Box 10, 50728 Kuala Lumpur, Malaysia
e-mail: [email protected]
T. Islam
e-mail: [email protected]
N. Ali
College of Information Technology, Universiti Tenaga Nasional Malaysia, Selangor,
Malaysia
e-mail: [email protected]

 Springer International Publishing Switzerland 2015 399


H.A. Sulaiman et al. (eds.), Advanced Computer and Communication
Engineering Technology, Lecture Notes in Electrical Engineering 315,
DOI 10.1007/978-3-319-07674-4_40
400 R.F. Olanrewaju et al.

40.1 Introduction

The rapid development of internet for web based application indicates a higher
demand of reliability, scalability, security and maintainability of coding method-
ology. PHP, a scripting tool for web that enable dynamic interactive web devel-
opment such intuitive, compiled fast, cross platform, open source, flexibility as
well as required minimal setup [1]. This became one of the important web
development language thus, PHP is one of the most powerful programming lan-
guage in the web world. Several developers choose to deploy application based on
PHP putting all the issues such as data access, business logic, and data repre-
sentation layer together [2]. This in turn create development problems especially
for big projects. To solve this problem, MVC design pattern brings an effective
ways to separate code in layers from each other based on each layer activities.
MVC design pattern is a proven effective way to develop application such as
CakePHP, CodeIgniter, Laravel, Symfony. The main methods of MVC to spilt an
application into separate layer that can work separately and produce same result.
The advantage of using MVC pattern are:
• Standard, consistency and predictability
• Software components or building-blocks so that developers can share and reuse
code [3]
• A model or standard architecture that allows easy visualization of how the
entire system works [4]
• Reusable and thoroughly tested code in the libraries, classes and functions [5].
• Well-structured code using architectural pattern [6].
• Security, interoperability and Maintenance.
Although MVC based framework (CakePHP, Laravel, CodeIgniter) has number
of advantages [7], however, selecting of best PHP framework is still a concern.
This is because all of the framework does not cover all aspect of web applications.
This study evaluate most famous PHP frameworks based on MVC design model
and it performance as well as proposed the best efficient PHP MVC framework for
future web development.

40.2 Materials and Methods

The operation of Model View Controller (MVC) method is to spilt or separate the
different parts of code into layers such as view, data access, controlling user’s
requests and forward request to relevant layers [8].
The MVC pattern’s title is a collation of three core parts: Model, View, and
Controller. A visual representation of a complete and correct MVC pattern looks
like the following in Fig. 40.1.
40 An Empirical Study of the Evolution of PHP MVC Framework 401

Fig. 40.1 MVC mechanism

MODEL
MA
NIP
TES UL
AT
DA ES
UP

VIEW CONTROLLER

SE
ES
ES
US
USER

Figure 40.1 shows the pattern and interaction with the user and the application
itself. It is a single flow layout of data, how it’s passed between each component,
and finally how the relationship between each component works.

40.2.1 Model

The Model is the name given to the permanent storage of the data used in the
overall design. It must allow access for the data to be viewed, or collected and
written to, and is the bridge between the View component and the Controller
component in the overall pattern [9].
One important aspect of the Model is that it’s technically ‘‘blind’’—by this, the
model has no connection or knowledge of what happens to the data when it is
passed to the View or Controller components [10]. It neither calls nor seeks a
response from the other parts of the component; its main purpose is to process data
into its permanent storage, seek and prepare data to be passed along to the other
parts.
The Model cannot simply be assumed as a database toolkit only, or a gateway
to another system which handles the data process [11]. The Model represents a
gatekeeper to the data itself, asking no questions but accept all requests which
comes its way. Often this most complex part of the MVC system, the Model
component is also the pinnacle of the whole system since without it there will be
no connection between the Controller and the View.
402 R.F. Olanrewaju et al.

40.2.2 View

The View is a module where data, requested from the Model is viewed and its final
output is determined. Traditionally in web application use MVC for development,
the View is the part of the system where the HTML is generated and displayed.
The View also ignites reactions from the user, who then goes on to interact with
the Controller. The basic example of this is a button generated by the View, which
a user clicks and triggers an action in the Controller.

40.2.2.1 Misconceptions About View

There are some misconceptions held about View components, particularly by web
developers using the MVC pattern to build their application. For example, many
mistaken the View as having no connection whatsoever to the Model and that all
of the data displayed by the View is passed from the Controller. In reality, this
flow disregards the theory behind the MVC pattern completely. Fabio Cevasco’s
article, The CakePHP Framework: Your First Bite [1] demonstrates this confused
approach to MVC in the CakePHP framework.
In order to correctly apply the MVC architecture, there must be no interaction
between models and views: all the logic is handled by controllers [13]. Further-
more, the description of Views as a template file is inaccurate. The View is really
much more than just a template, the modern MVC inspired frameworks have
bastardised the view almost to the point that no one really cares whether or not a
framework actually adheres to the correct MVC pattern or not. It’s also important
to mention that the View part is never given data by the Controller. There is no
direct relationship between the View and the Controller without the Model in
between them.

40.2.3 Controller

The third component of the triad is the Controller. Its job is to handle data the user
submits as well as update the Model accordingly. The Controller can be summed
up as a collector of information, which then passes it on to the Model to be
organized for storage, and does not contain any logic other than collecting user
input [9]. The Controller is also only connected to a single View and to a single
Model, making it a one way data flow system, with handshakes and signoffs at
each point of data exchange. Controller is only given tasks to perform when the
user interacts with the View first, and that each Controller function is a trigger, set
off by the user’s interaction with the View [14]. The most common mistake made
by developers is confusing the Controller as a gateway, and ultimately assigning it
functions and responsibilities that the View should do (this is normally a result
of the same developer confusing the View component as a template).
40 An Empirical Study of the Evolution of PHP MVC Framework 403

Additionally, it’s a common mistake to assign the Controller functions that gives it
the sole responsibility of crunching, passing, and processing data from the Model
to the View. Nonetheless, the MVC pattern relationship should be kept between
the Model and the View.

40.3 MVC Design Frameworks

40.3.1 CodeIgniter

CodeIgniter is an open source rapid development web application framework, for


use in building dynamic websites with PHP. Its goal is to enable to develop
projects much faster than writing code from scratch, by providing a rich set of
libraries for commonly needed tasks, as well as a simple interface and logical
structure to access these libraries. The first public version of CodeIgniter was
released on February 28, 2006, and the latest stable version 2.1.4 was released July
8, 2013 [15].
CodeIgniter is loosely based on the popular Model-View-Controller develop-
ment pattern. While view and controller classes are a necessary part of develop-
ment under CodeIgniter, models are optional. CodeIgniter is most often noted for
its speed when compared to other PHP frameworks.

40.3.2 CakePHP

CakePHP is an open source web application framework. It follows the Model-


View-Controller (MVC) approach and is written in PHP, modeled after the con-
cepts of Ruby on Rails, and distributed under the MIT License [16].
CakePHP uses well-known software engineering concepts and software design
patterns, as Convention over configuration, Model-View-Controller, Active
Record, Association Data Mapping, and Front Controller.

40.3.3 Symfony

Symfony is a PHP web application framework for MVC applications. Symfony is


free software and released under the MIT license. The symfony-project.com
website was launched on October 18, 2005 [17].
404 R.F. Olanrewaju et al.

40.3.4 Laravel

Laravel is a free, open source PHP web application framework, designed for the
development of MVC web applications. Laravel is released under the MIT license,
with its source code hosted on GitHub.
The key design points of Laravel are:
• Bundles provide Laravel with a modular packaging system, and numerous
bundled features are already available for easy addition to applications.
• Eloquent ORM is an advanced PHP implementation of the active record pat-
tern, providing internal methods for enforcing constraints to the relationships
between database objects [18].
• Application logic is part of developed applications, either by using controllers,
or as part of route declarations. Syntax used for definitions is similar to the one
used by Sinatra framework.
• Reverse routing defines a relationship between links and routes, making it
possible for later changes to routes to be automatically propagated into relevant
links. When links are created by using names of existing routes, appropriate
URIs are automatically created by Laravel [19].
• Restful controllers provide an optional way for separating the logic behind
serving HTTP GET and POST requests.
• Class auto loading provides automated loading of PHP classes, without the
need for manual maintenance of inclusion paths. On-demand loading prevents
loading of unnecessary components; loaded are only those components which
are actually used [20].
• View composers are logical code units that can be executed when a view is
loaded.
• Migrations provide a version control system for database schemas, making it
possible to associate changes in the application’s code base and required changes
in the database layout, easing deployment and updating of applications [21].
• Unit testing plays an important role in Laravel, which itself has a large number
of tests for detecting and preventing regressions. Unit tests can be run through
the artisan command-line utility [22].
• Automatic pagination simplifies the task of implementing pagination, replacing
the usual manual implementation approaches with automated methods inte-
grated into Laravel [23].

40.4 Benchmarking

To evaluate the performance of four mentioned PHP frameworks; CodeIgniter


(CI), Symfony, CakePHP and Laravel. The best way to do the benchmarking is
by applying several criteria such as request per second, system load average,
40 An Empirical Study of the Evolution of PHP MVC Framework 405

memory usage, number of function calls and number of files required on each of
the MVC. To evaluate these four frameworks, web design which contains ‘‘hello
word’’ was carried out on apache (ab –c 200 –n 50,000), below are results of each
evaluation criteria.

40.4.1 Request per Second

This benchmarking is based on apache (ab –c 200 –n 50,000). Figure 40.2 shows
the performance comparison among four MVC: CI, CakePHP symphony and
Laravel. It can be seen that Laravel outperforms other MVC in terms of request
person. It was able to handle 3,000 request per second compare to others. In this
case, bigger output indicates perfect result hence, it denotes best performance.

40.4.2 System Average Load

The system average load is measure in relation to time. that is, in 1 min when
Apache Benchmark is complete, the smaller is better in the condition of (ab –c 200
–n 50,000). Figure40.3 shows the comparison of the four MVC in terms of system
load within 1 min. In this graph, Laravel contain lowest times (0.98) where
CakePHP contain maximum load time 5.1 per minute to load system. Based on
average time, lowest average time is better to run MVC application.

40.4.3 Memory Usage

This benchmarking checks how much memory is used in a one word ‘hello world’
page display. The smaller number of KB the better the memory usage. Figure 40.4
indicated that Laravel is about 518 KB compare to CI which is which 725 Kb

Fig. 40.2 Request per


second among PHP
framework
406 R.F. Olanrewaju et al.

Fig. 40.3 System average


load time

Fig. 40.4 Memory usage

follow by symphony with memory usage of about 1,711 then CakePHP with
2,824 KB. Hence, it can be concluded that Laravel memory usage is efficient.

40.4.4 Response Time

The time of page request to response from framework is one of the most important
criteria to evaluate MVC performance. It is calculated in millisecond. The lower
number of millisecond calculated the better performance. Figure 40.5 depicts the
result of all the four MVC used. Among all, Laravel came out to be with the least
response time, 4.46 ms compare to CI with 7.2 followed by symphony with 12
then CakePHP with about 14 ms.
40 An Empirical Study of the Evolution of PHP MVC Framework 407

Fig. 40.5 Response time for


various MVC

Fig. 40.6 Numbers of


functions called

40.4.5 Number of Function Calls

This test checks how many functions are calling for one ‘‘hello world’’ pages in
terms of Facebook XHProf [24]. Here smaller number of functions is most
effective for PHP framework evaluation. It can be seen from Fig. 40.7, Laravel
outperforms other MVC framework with the minimal number of function calls
with 238 calls compare to CakePHP 834 and others (Fig. 40.6).

40.4.6 Number of Files

The number of files included or required in one ‘hello world’ page. Less amount of
required files represent that such framework will be loaded first in-terms of file
408 R.F. Olanrewaju et al.

Fig. 40.7 Numbers of file


are required by various MVC

running. Smaller numbers of required files are highly appreciable. As shown in


Fig. 40.7, CI comes up with the least file of 22, then symphony with 15 files
followed by Laravel with 26, while CakaPHP loaded 37 files. Here CI outperforms
other frameworks

40.5 Results and Discussion

Based on different core criteria of PHP framework such as benchmark, pattern,


database access, field database, session, cache and library, this research compare
among four top PHP framework (Laravel, CakePHP, CodeIgniter and Symfony)
and their performance. Table 40.1 shows comparisons the frameworks in terms of
facilities.
From the Table 40.1, it is assumable that, Laravel has advantage over other
MVC PHP framework.
The four frameworks was also measured based on current trends for the future
PHP framework that will lead the next generation of web. Figure 40.2 shows the
details.
From Fig. 40.8, it is shown clearly that, Laravel took almost 26 % place in
world web development in 2013 by MVC pattern framework. Based on this
analysis, it is understandable that, Laravel is going to be one of the most famous
MVC pattern framework in PHP world with huge flexibility of deployment as well
as manage.
40 An Empirical Study of the Evolution of PHP MVC Framework 409

Table 40.1 Comparism among four MVC framework

Specification CakePHP CodeIgniter Laravel Symfony


MVC
DB
Fielddb UK
Auth
Validate
Session
Cache
Ajax UK
Db Eloquent
MVC type PMVC UMVC HMVC UMVC
MVC db AR AR ORM ORM
Upload
Form Objects Procedural Objects Objects
Xml
library UK

Fig. 40.8 Compare among


Laravel
all MVC-PHP framework
based on current trends 13.52% Phalcon
4.51%
Symfony
1.50% 25.85%
Codeigniter

7.52% Yii
Cake PHP
4.51% Zend
16.73%
7.62% Pear
Aura
7.62%
10.62% Others

40.6 Conclusion

An empirical study on major MVC pattern for PHP framework has been evaluated
in this paper.
The results obtained from evaluating the four frameworks: CodeIgniter (CI),
Symfony, CakePHP and Laravel using criteria such as request per second, system
load average, memory usage, number of function calls and number of files required
as well as available facilities in each framework. It shows that the Laravel out-
performs other MVC framework. A request per second of as high as 3,000 was
recorded for Laravel compare to others like CakePHP with as low as 750 request
per second. The results obtained for all other parameters such has storage, function
calls, number of files, response time etc. indicated that Laravel has huge flexibility
410 R.F. Olanrewaju et al.

of development of web application, it has more facilities for programmers that


makes it acceptable to all web programmer in terms of different criteria such as
intuitive, compiled fast, cross platform, open source and flexibility. It enable easy
migration, enriched library, template system, eloquent ORM and wide range of
community support that helps to develop application smoothly. All the criteria and
facilities of Laravel prove that, it is of opinion that Laravel would be the best
choice to deploy next generation PHP based web application.

References

1. Bergmann, S., Kniesel, G.: GAP: generic aspects for PHP. In: Proceedings of EWAS’06
(2006)
2. Bakken, S.S., Aublach, A., Schmid, E., et al.: PHP manual (The PHP Documentation Group).
https://php.net/manual/en/index.php, Accessed 10 March 2014
3. Nakajima, S., Hokamura, K., Ubayashi, N.: Aspect-oriented development of PHP-based web
applications, 34th annual IEEE computer software and applications conference workshops
(2010)
4. Veglis, A., Leclercq, M., Quema, V.: PHP and SQL made simple distributed systems online,
Volume 6 Issue 8, August 2005, Page 4
5. http://webcoderpro.com/blog/top-6-most-popular-php-frameworks-of-2013/. Accessed 21
Jan 2014
6. http://www.catswhocode.com/blog/top-10-php-frameworks-for-2014. Accessed 23 Jan 2014
7. http://www.sitepoint.com/best-php-frameworks-2014/. Accessed 20 Jan 2014
8. Ricca, F., Tonella, P.: Analysis and testing of web applications. In: Proceedings of 23rd
ICSE, pp. 25–34 (2001)
9. http://www.tonymarston.net/php-mysql/model-view-controller.html. Accessed 13 Dec 2013
10. Cui, W., Huang, L., Liang, L.J., Li, J.: The research of PHP development framework based on
MVC pattern, 4th international conference on computer sciences and convergence
information technology (2009)
11. http://www.sitepoint.com/the-mvc-pattern-and-php-1/. Accessed 15 Jan 2014
12. http://www.sitepoint.com/application-development-cakephp/. Accessed 17 Jan 2014
13. Enderlin, I., Giorgetti, A., Bouquet, F.: A constraint solver for PHP array, 6th international
conference on software testing, verification and validation workshops (2013)
14. http://matrix.include-once.org/framework/simplese. Accessed 19 Jan 2014
15. http://en.wikipedia.org/wiki/CodeIgniter. Accessed 10 Mar 2014
16. http://en.wikipedia.org/wiki/MIT_License. Accessed 28 Feb 2014
17. http://en.wikipedia.org/wiki/Symfony. Accessed 11 Mar 2014
18. http://www.developed.be/2013/07/16/php-frameworks-which-to-choose/. Accessed 16 Jan
2014
19. http://brianretterer.com/why-laravel-is-the-best-php-framework/. Accessed 15 Jan 2014
20. http://www.ruilog.com/blog/view/b6f0e42cf705.html. Accessed 8 Mar 2014
21. http://www.webdesignermag.co.uk/features/laravel-a-modern-php-framework/. Accessed 17
Jan 2014
22. Merlo, E., Letarte, D., Antoniol, G.: Automated protection of PHP applications against SQL-
injection attacks, 11th European conference on software maintenance and reengineering
(2007)
23. http://en.wikipedia.org/wiki/Laravel_(framework). Accessed 9 Mar 2014
24. http://www.php.net/manual/en/intro.xhprof.php. Accessed 10 Mar 2014

You might also like