未加星标

PHP Frameworks Code Complexity Comparison

字体大小 | |
[开发(php) 所属分类 开发(php) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

Last week as I was refactoring and cleaning Laravel for the 5.4 release, Graham Campbell showed me some code complexity statistics for the framework. I decided to compare this against some otherphp frameworks to see how Laravel stacks up.

I looked at a few metrics. One is average method complexity which is a measurement of Cyclomatic complexity . When looking at this score, lower is better . While not an absolute “end-all” metric to measuring code quality, it does give a decent indicator of “hot spots” in your code that could use refactoring.

I was pleased to see Laravel has the lowest average method complexity of any of the frameworks measured. In addition, Laravel does not contain any method longer than 13 lines of code. The only two frameworks with a maximum method complexity under 50 were Laravel (17) and Slim (13). No framework other than Laravel had an average method complexity under 2.

It is worth noting that Laravel utilizes Symfony’s HTTPFoundation component and Console component. No other Symfony components are heavily utilized throughout the framework. The primary goal of this comparison is to compare how *I* personally write code vs. how other projects are writing code. All project’s measured have a large enough sample size of pure, first-party code to accurately measure that.

I also measured Laravel’s Eloquent ORM against Doctrine’s ORM. The results of that comparison can be found at the bottom of the result listing. Laravel Lines of code: 54,398 Longest method: 13 lines of code Average method complexity: 1.62 Maximum method complexity: 17 Percentage of methods that are non-static: 94.81% Symfony (Only Components, No Twig, No Doctrine) Lines of code: 118,636 Longest method: 136 lines of code Average method complexity: 2.72 Maximum method complexity: 155 Percentage of methods that are non-static: 97.09% Zend (Minimal Installation Option Selected) Lines of code: 55,904 Longest method: 73 lines of code Average method complexity: 2.76 Maximum method complexity: 53 Percentage of methods that are non-static: 93.55% Cake Lines of code: 62,860 Longest method: 56 Average method complexity: 3.30 Maximum method complexity: 75 Percentage of methods that are non-static: 89.87% Slim Lines of code: 4,127 Longest method: 26 Average method complexity: 2.40 Maximum method complexity: 13 Percentage of methods that are non-static: 96.58% Eloquent (ORM) Lines of code: 6,026 Longest method: 13 Average method complexity: 1.76 Maxium method complexity: 17 Percentage of methods that are non-static: 91.57% Doctrine (ORM Only, No DBAL) Lines of code: 39,294 Longest method: 148 Average method complexity: 2.94 Maximum method complexity: 152 Percentage of methods that are non-static: 92.50%

本文开发(php)相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师

主题: LaravelPHP
分页:12
转载请注明
本文标题:PHP Frameworks Code Complexity Comparison
本站链接:http://www.codesec.net/view/522944.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(php) | 评论(0) | 阅读(22)