Comparison of the amount of code of popular frameworks

    Hello, Habr. Every year the number of frameworks increases, forks appear, some become fashionable, and some go out of fashion. Of course, different frameworks provide the developer with different opportunities, which primarily depend on the developers, their ideas, the chosen architecture, the availability of documentation ... and of course the size of the framework. We’ll talk about this parameter today - I’ll ask everyone interested under cat.

    Let's look at the question from the point of view of a beginner. Here he has already learned the basics, writes something on the "native" php. Gradually comes to such a concept as a "framework". And now he is already interested in this issue, googled which frameworks are the most popular, which have documentation in Russian, and which have a community. However, there is still such a parameter as complexity or entry threshold. And if he asks for advice on the forum, then he will most likely be advised by Codeigniter or Kohana (less often Yii) than Zend Framework or Symfony. And this is quite logical and normal.

    Is a large framework good or bad? Which is better: good performance or excellent architecture and features? We will leave these questions for the following articles, and today we look at the smallest and largest and most voluminous frameworks. And we will count the number of lines and the number of files.

    On the network you can find information about the number of lines of a particular framework. But this information seemed unreliable and quite outdated to me (I consider 1-2 years a big gap in the industry), so I decided to get this data myself by counting. This raises the question: what exactly are we going to consider? Reflecting on this issue, I came to the conclusion that the following parameters should be calculated:

    • The number of lines and files in the whole framework
    • The number of php files and lines in them throughout the framework
    • The number of php files and lines in them throughout the framework excluding third-party components

    For this purpose, a small php script was written that recursively received all the files in the folder, opened them and counted the number of lines. Also along the way we save the number of files.

    The experiment was attended by popular frameworks (if I forgot your favorite - write, add) and several CMS / CMF for clarity. When measuring, we used the latest versions from developer sites.

    As a result, I received the following data:

    Object of studyCompletelyOnly php filesOnly php files (without third-party modules)
    Kohana 3.3.0   
    files1283 862471 
    Codeigniter 2.1.3   
    files352 147 147 
    Yii 1.1.13   
    files2005 1621 1571 
    Zend Framework 2.1.3   
    files2070 1963 1963 
    Symfony 2.2.0   
    files5718 3583 2247 
    CakePHP 2.3.0   
    files1012 654 654 
    FuelPHP 1.5.2   
    files700 473 455 
    Drupal 7.2.0   
    files1056 269 269 
    Joomla 3.0.3   
    files47531651 1651 
    Wordpress 3.5.1   
    files1085 447 447 

    And if you find the approximate number of lines per file (when calculating, the data was “only php files without third-party components”):

    Object of studyLines / file (average)
    Kohana 3.3.0120.7515924
    Codeigniter 2.1.3350,5102041
    Yii 1.1.13364,8084023
    Zend Framework 2.1.3139,0509424
    Symfony 2.2.0112,776146
    CakePHP 2.3.0364,4495413
    FuelPHP 1.5.2160.6989011
    Drupal 7.2.0561.3345725
    Joomla 3.0.3184,128407
    Wordpress 3.5.1430,5883669

    So, let's analyze the data. The largest (by the number of files) in the standard delivery is the Symfony framework, and the largest - Yii. The most concise (least files) is Codeigniter.
    According to the average number of lines in a file, the frameworks were divided into 2 groups: 110-160 lines in a file (Kohana, Zend, Symfony, FuelPHP) and 300-500 lines in a file (Codeigniter, Yii, CakePHP), but there aren’t any average ones. Most likely this is due to architecture and you should not take these values ​​very seriously.

    As for the CMS / CMF, the results are very expected and may contain a large error, because they contain a fairly large number of elements related to the frontend.

    In conclusion, I would like to note that the results were quite predictable. However, it is not necessary to focus much attention on such a parameter as the size of the framework. The programmer, knowing all the pros and cons of each option, must choose a tool for a specific task and use its advantages.

    UPD: In the comments they suggested to compare the number of characters without comments. I conducted such a test: only php files, without comments, transfers, the number of characters is considered (utf-8 is taken into account).

    Object of studySymbols (no comments, hyphenation, third-party libraries)
    Yii 1.1.1313248904
    Symfony 2.2.05769403
    CakePHP 2.3.05365166
    Zend Framework 2.1.35334742
    Zend Framework 2.1.3 (without Res / lang)4924887
    Yii 1.1.13 (without i18n data and messages)1811665
    FuelPHP 1.5.21209799
    Kohana 3.3.0841022
    Codeigniter 2.1.3616417

    Also popular now: