PHP FRAMEWORKS COMPARISON: ZEND, CODEIGNITER, AND YII PHP

In PHP, the most important frameworks are : Zend, Symfony, Codeigniter, Yii y Cake PHP. It is a good idea spend some hours in learn a bit how run these frameworks, because each one presents details that may be more or less interesting for developers.

Choosing a PHP framework is not an easy task, especially if you have relatively little experience in PHP to know what makes a good framework or and what doesnt, but choosing the right PHP framework for the job is absolutely critical in the long term as choosing the wrong PHP framework can lead to a number of negatives, such as longer development time, need for more experienced staff who may be hard to find and of course performance problems.

Firstly, start with Zend Framework.

Latest Zend Frame work version: Zend Framework 2.2.6
Official Site: http://framework.zend.com/
Zend Framework is actually quite a nice framework in terms of its completeness and the fact that it is properly designed in terms of OO and lets you do things the way you want to do them without forcing you to learn some new language.  However, I have a number of issues with Zend Framework. I have just began digging into Zend myself recently and these are the problems I have come across and expect others to run into as well, at least in the near future while these problems exist in the most recent versions of Xampp and the Zend Framework.

1. When creating your framework project: php.exe is not recognized as an internal or external command, operable program or batch file.

2. When creating your controller in a new project: A project profile was not found.

3. You have an existing v1.9.0 project but receive the same error after using the guide above: A project profile was not found.

Advantages:
1. Official produced, comes with a lot of library, the framework itself uses a lot of design patterns to write, very elegant structure, the efficiency of medium; MVC design, relatively simple, with routing capability, more powerful configuration file (to handle XML and php INI), a variety of library is very powerful, is all the PHP frameworks kinds of features the most comprehensive, including not only is a PHP framework, it is a big class library (instead of PEAR), which is its main feature; to support intuitive operation in addition to the database outside of the Model layer (stronger than Codeigniter and CakePHP ), and can very easily loaded using the Loader functions of other newly added Class; Cache feature is very powerful, from the front to the back-end Cache support, back-end Cache support Memcache, APC, SQLite, files, etc. methods; database operations very powerful, supporting a variety of drivers (adapters).
2. Documentation is very full, very mature community in the country, and many Web 2.0 sites currently in use, the cost of learning medium.

Disadvantages:

1. MVC feature complete weak, View layer simple to achieve (with no realization of the same), not very strong control of the front page
2. There is no automated scripts, create an application, including the import file, all have their own hand-built, entry costs are high
3. Zend Framework application framework as a medium is not, and can barely as large PHP application framework, but as a very mature for large-scale PHP framework, but also need some work.
4. The configuration cliff – once you go further than the configuration of your framework your productivity drops right off, it can be difficult to implement features outside of a frameworks configuration.

Secondly Codeigniter Frame Work

Current Version: Codeigniter 2.1.4
Official Site: http://ellislab.com/codeigniter/
There are a few things about Code Igniter that people really love, being the huge community and the simplicity.  It is not doubt quite an easy framework to pick up for a novice; however, it also has a number of drawbacks. Firstly, the old version of CI being is still backwards compatible with PHP 4.  This means un-necessary code and all kinds of other crap. The second thing is that although its quite a complete framework it actually lacks many of the things you actually want when you develop serious complex applications (not just some little amateur website). These things include proper support for templates, user controls (or widgets as they are called in Yii), integration with jQuery and all kinds of other little things. I would really love if there was a framework as simple as codeigniter in its structure, but which used more proper OO techniques, the likes of Autoloaders, did not do unnecessary stuff like define .php in a separate constant which is appended everywhere and so on. we will be more than happy to manually instantiate the objects I required in some init file and do a few more things manually rather than relying on the framework to magically do them for me.  If there was such a framework I would more than happily use it for little projects, but unfortunately there is not one.  The closest thing I have found to this is the PHP Pro MVC framework tutorial and the framework used in OpenCart (although I thing it has some shortcomings too). Unfortunately, Code Igniter is not this framework and falls short of what I would want for a simple framework.

Advantages of CodeIgniter:
1. Easy and hassle-free migration from server hosting to server hosting.
2. Easy to learn, adopt and deploy
3. Easy handling and customizing.
4. A new functionality has been applied without affecting the customization at all.
5. Offers flexibility and easy management With MVC based framework.
6. Active Record Implementation is simply superb and easy to remember.
7. Provides easier configuration and customization of configuration files.
8. Facilitates easy working with a variety of developers.
9. Good collection of possessed libraries.
10. Awesome documentation of the user guide, which makes it easy for any coder to use the whole framework.
11. Enables to incorporate its own existing scripts as well as develop core libraries for the system
12. Lightweight and extensive.

Disadvantages of CodeIgniter:
1. Its PHP based only and not very object-oriented in some parts
2. PHP4 legacy code
3. Company-driven instead of community-driven
4. Irregular releases
5. Framework itself has no built-in ORM (only via 3rd party solutions).

Benefits of CodeIgniter:
1. A small track and outstanding presentation
2. Provision of broad compatibility along with standard hosting accounts
3. Configuration and normal coding rules are not required
4. Depiction of straightforward solutions
5. Free from complex structures and development

Finally, I come to Yii.
Currently there are two versions of Yii: 1.1 and 2.0.
Yii 1.1 is the latest stable version.
The latest release of Yii 2 is 2.0.0 alpha.
Official Website: http://www.yiiframework.com/

I guess the thing with Yii is that it fits in nicely right between Zend Framework and Code Igniter. It is probably not the simplest to learn for a PHP or OO novice, but for an experienced OO developer it is a breeze. It has great documentation and if need be you can always inspect the code yourself. It has used some of the best concepts from ASP.NET and from many other frameworks and because it is strict PHP5 and strict OO (without crazy hacks that are typical of inexperienced PHP developers). it i s very very easy to learn and understand as long as you understand the basic principles of OOP even if you have little experience in PHP. The thing with Yii is that it is more comprehensive than CodeIgniter and better structured, yet smaller and more robust than Zend Framework, requiring a hell of a lot less code to get stuff done, while giving you all the same features and more (e.g. Code generation with Gii). Yii, for no doubt is the best php framework currently in the industry. What makes Yii special?  Have a look at these 14 exceptional features.

1. Fast
Check out the differences in how many RPS (Requests per second) other frameworks can process compared to Yii. Yii is very much known for its speed. Applications developed in yii loads very fast. It is light weighted and the code is very much optimized . The lazy loading technique improves the speed of Yii. It neither loads a class until its used   nor creates an object until its accessed for the first time.

2. CRUD Feature
Yii got the CRUD feature. This literally saves heaps of time and makes our process much easier. For instance, if we are building a user creation form, we just need to create the User table and the required fields in the database. And using Gii (link)((a powerful tool of Yii to generate models and controllers) we can easily generate the User model and its CRUD. Thats all and we got the user create, update, delete and manage system all in two or three clicks

3. Database tables as objects (so that we dont need to query all time).

We can create model instances. The database modification with these model instances helps you to avoid complex queries and make your tasks easy. The

CDBCriteria of Yii helps to process very complex database queries easily.

Yii applications can be switched to different databases without any difficulties. Yii got a query builder, and it generates the query. This prevents sql injection and other attacks.The ORM approach turns tables into classes and rows into objects.

3.1 Relations
Relations are one of highlight features of Yii. You can define the relation between multiple tables say One to One, One to Many etc so that we access the related data in a single object avoiding all the complete JOIN (Inner, Outer) queries of SQL.
Consider two tables User and Profile. User table contains the authentication details and Profile table contains the personal details of the user. We have defined a Has One relation (User have one profile) in the User model.
‘userprofile’=>array (self:: HAS_ONE, ‘Profile’, ‘userID’)
We ve set a relation named userprofile and we can access the related profile data through,
$user->userprofile->phonenumber
Where phonenumber is the profile user phone number in the profile table.

4. Easy Form Validation.
Working with form and its validation is one of the essential stuff for any website. Using Yii, you can connect your forms with the models (database tables). You can set validation rules for the model. For instance consider a User model (the user database table for user registration) and there is a field username in it.
Array (‘username’,’required’);

We can set Yii validation rule for the username. And then we create a new object of the User model class and create a form field for username in the user registration page.
echo $form->textField ($user,’username’);
where $user is the User model instance and ‘username’ is the database field for user name. We have created a €œrequired” validation rule for the user name so it gets handled automatically. Once the from is submitted with empty user name field, the error will show up automatically.

5. Great support for JQuery and Ajax.
There are lots of widgets in Yii which have ajax and jQuery support. It do have the jQuery dialog, date picker and all so that we just need to call the widgets. We can also send ajax requests easily using the inbuilt ajax buttons in yii.

6. Inbuilt Authentication and Authorization
6.1 Authentication
Yii has a default login system, in which we can authorize our user. We just need to connect our User model into it. It got all the essential features required, say session, cookies, error handling etc. We can also manipulate the login system easily

6.2 Authorization
Yii got inbuilt role based access controls through which we can create roles to the users. We can limit the access to different sections based on the roles.
If (Yii::app()->user->check Access(‘createUser’))
{
// Create the user
}
Here we have created a task called create User and if the user have permission to the task (creating a user) , he can create a user.
Yii also got access Rules through which we can easily block or allow, logged in, logged out or other users to an action.

7. Theming
Yii applications got theme directory inside so that we can set the theme for the application. Also we can switch easily to different themes inside the config file. This helps the designers to implement designs very easily.

8. Web Services (API Support).
Yii helps easy generation of web services. We can create an action and define a web service action to it (just 1 line code). And if we try to access the action as a url what we see would be a bulk of xml contents.

9. Caching
Caching helps to improve the performance and speed of your website. Yii helps you to integrate different caching components on different scenarios. This reduces the time required for page load to a great extent.

10. Error Handling
Yii provides great support for error handling. Yii have handleError and handleExcpetion methods, which handles all the php warnings and notices. Through Yii, we can raise exceptions (there are lots of built in exceptions). For example, if a user is requesting an invalid page, we can handle it buy just adding, throw new CHttpException (404,’The specified page cannot be found.’);
And this will raise the 404 errors, which is what we require in such a scenario.

11. Security
Yii is highly secured. Three major types of attacks to a website are.

11. 1. Cross-site Scripting (XSS)
A typical example is the attack in a poorly made up forum. User can enter malicious javascript code to the forum and it will appear in the forum page. Yii checks for the javascript and malicious codes entered and is capable of blocking those malicious codes form being entered into the website. CHtmlPurifier (inside Yii) does this purpose.

11. 2.Cross-site Request Forgery (CSRF)
These types of attacks are mainly responsible for money loss (mainly from banks). Yii makes the $_GET requests to retrieve data only, not to change anything in the server.

11. 3.Cookie attacks
Yii got a cookie validation method, which blocks cookies from being modified.
12. Extensions
Yii do have lots of extensions. some what like plugins for wordpress. This makes the complicated development and 3rd party api handling very easy for yii. The twitter bootstrap extension is one of the most rated yii extension. This helps you to integrate twitter bootstrap for your application easily.
13. Testing
Yii do have Unit testing and functional testing feature, which helps you in testing and improving your code quality.
14. Great Documentation
Yii do have one of the best documentation system compared to all other frameworks. Each and every single method is documented clearly and thoroughly.

Print Friendly

Leave a Reply

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