Re-examine the PHP framework CodeIgniter VS Zend

Source: Internet
Author: User
Tags filter command line comparison include php framework query zend zend framework
We plan to start a new project from scratch and evaluate some PHP frameworks for this. Our alternative list is cake, CodeIgniter, Symfony and Zend. We used each of these 4 frameworks to write an identical small application (a simple wiki application) and hopefully we can choose the one that is most appropriate as soon as possible.

Statement: I will try to ensure my objectivity, although I am a coldeiginter enthusiast. The company I work for is a partner of Zend (we've used Zend Platform and Zend Studio).

Although the first plan was to evaluate 4 frameworks, this article is actually a direct comparison between the CodeIgniter and the Zend Framework. After spending a few hours studying the 4 frames, I had to exclude symfony and cake from the list. The reasons are as follows:

Learning Curve Learning curve
Symfony and Cake both have a very steep learning curve. Cake has strict rules: Data indicates this, file location, method name, and class name. Symfony uses the. yml format (which requires learning, although it is not really difficult) to store configuration information, and a large number of operations need to be done through the console (console), creating data tables, data models, and many other files using the command line.

Strict ORM: Strict ORM
Symfony and cake both have a mature object-relational mapper (object-relational mappers ORM) that provides access to data, but this feature is hard to disable unless a lot of effort is made. These ORM have strict rules and conventions that must be followed. In contrast, the Zend Framework and CodeIgniter are very flexible on whether to use models and how to use models. The use of models is optional, although they all have data mapper (mappers), but no such applications can be made (developed). The application of the data operation will be extremely dense and fine (intensive), and we do not want to be constrained by the choice.

Flexibility: Flexibility
The Zend framework and CodeIgniter are more flexible than the other two frameworks.

Final comparison

  CodeIgniter Zend Framework

Set up initial Build

CodeIgniter is easy to initialize. It's a good start to copy all the files from the frame to the Web server. Its folder is also small-about 2.1 trillion. From the start, 5 minutes later, I can show the default home page. The Zend framework needs some trouble, it needs to create a bootstrap file and fill in all the initialization settings. By comparison, the frame is a bit larger-about 12.4MB. The entire initial build process is used for approximately 19 minutes.

Document

The structure and organization of the document is fairly good, but not as detailed as the Zend Framework. CodeIgniter has forums and wike, there are a lot of user-submitted code. The Zend framework has very detailed documentation, and there are many examples. In my opinion, its document structure is inferior to codeigniter, which may be affected by the details mentioned above and the large number of usable parts. ZF also has a wiki with a small number of tutorials.

Template

CodeIgniter includes a template parser class, which, in my view, is limited because it does not support logic (for example, if statements). In any case, CI recommends using PHP tags in the template (view). ZF includes a layout class that provides a common layout (or multiple layouts) for the entire site or application. It uses PHP tags directly in the template, and it also provides an abstract view class that can be extended using a Third-party template library.

Component

CI has many libraries and helpers to simplify the development process. Although these are less than ZF, in general, the usage is simpler (while it does have less the than ZF, in the main, the usage of the CI variants is simpler). ZF has a huge amount of classes and components. They have good documentation but are slightly more complex to use than CI.

Data access

CI has a database class for processing database connections. This class can use standard SQL queries to create, retrieve, update, and delete using standard PHP methods. CI also provides an active record class, which is a modified version of the active recording mode (Active records Database pattern). This pattern allows you to use less code to retrieve, insert, and update data. In some cases, only 1 to 2 lines of code are required to perform a data operation. In addition to simplifying, one of the main benefits of active logging is that it can create an application that is not dependent on the database, because the query statements are generated by different database adapters. It also considers the security of the query, and the system automatically makes the variable escape. ZEND_DB and its related classes provide a simple SQL database interface for ZF. It receives standard SQL queries but simplifies the process of getting query results. It also includes an ORM, using the table data gateway and the Row data gateway. They package data tables and data rows into objects, and greatly improve the development speed. The disadvantage is that there is a slight loss of performance compared to the modified version of CI used for active record pattern (no extensive use of objects). ZEND_DB can also handle table relationships. (zend_db can also model table relationships in PHP classes making database joins a breeze.)

Flexibility

CI is very flexible and almost all default settings can be modified. ZF in fact a simple collection of classes, all files and directories can be placed anywhere, as long as these locations are added to the bootstrap file.

Verify

In CI, data validation is handled by a validation class. Some rules are defined and given to the validation object (object), which verifies that the objects are automatically validated from the URL or the data submitted by the form. Programmers can decide how to handle these gains. Validation classes can also help you automatically set error messages for the specified fields. Zend_validate provides a common set of validators. It also provides a simple validator connection mechanism in which multiple validators can be applied to a single data (datum) in a specified order. In ZF, each validator is a different class, the class is added to the data (like a filter), rather than a CI, the data is passed into the class. In ZF, each validator is a separate class and the class are added to the "data" (like a filter) rather than the data being PA Ssed into the class like it's in CodeIgniter.

Form

The form helper file in CI contains functions to help you manipulate the form. Its role is to generate form fields, but writing HTML is still unavoidable. Zend_form simplifies the creation and processing of forms. It handles element filtering, validation, escaping data, form generation (rendering). Using ZEND_FORM,ZF, you can use PHP to completely wrap a form, including labels, validation, and error messages.

Performance

CI has about twice times the performance of ZF ZF is about half as slow as CI

Test

CI has a unit test class, but it encourages mixed test code and real code, which I do not recommend. It may be possible to use a third party extension for simple testing. A third-party Extension for simpletest is available though. It is also possible to use PHPUnit with CI classes. ZF does not have a built-in test class, but its core classes use PHPUnit as a test framework that can be extended to include all of the additional classes this can is extended to include any additional classes. The use of simpletest in ZF is also feasible.

Internationalization

NO YES

Authorized

Bsd-style New BSD



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.