TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

PHP Frameworks Code Complexity Comparison

33 pointsby sconxuover 8 years ago

8 comments

ehntoover 8 years ago
It&#x27;s co-location is very low however. What you want is never nearby, and thanks to the Facade system used for service location it also isn&#x27;t always clear which class is actually being used without digging through some configuration files, and an IDEs autocomplete and click through has no hope without a generated helper file.<p>This leaves you digging through dozens of tiny files, some barely longer than the class definition itself, just to find even high level logic. I normally learn frameworks by simply reading the code, but I can&#x27;t help but feel fatigued when having to try and find where a line of logic actually lives in Laravel. It is almost always a journey.
评论 #13366096 未加载
评论 #13365228 未加载
评论 #13365524 未加载
评论 #13365431 未加载
rc_bhgover 8 years ago
I don&#x27;t think this is a good argument for or against any framework. It&#x27;s just an interesting side note.
评论 #13366184 未加载
评论 #13365831 未加载
throwaway2016aover 8 years ago
Bulleted lists are a terrible format for this. This is exactly what tables were made for. It&#x27;s hard to do a comparison if it&#x27;s not side-by-side.
debacleover 8 years ago
Doctrine is complex because it does a lot of magic. It&#x27;s a good framework for anyone who is willing to learn it.<p>Slim + Doctrine is a pretty good stack. Pick your favorite templating format and away you go. I think anyone else in modern PHP is generally overkill.
mywittynameover 8 years ago
IMHO, most of the metrics picked for this comparison are useless.<p>Longest Method: Sometimes the functionality provided by a method is irreducible. And breaking off chunks of it into other one-time-use methods just to reduce method length can be detrimental to readability and understanding. This is a judgement call and it&#x27;s not really &quot;bad&quot; unless it&#x27;s &gt;1000LoC.<p>&quot;Complexity&quot;: Cyclomatic complexity is a near-worthless metric, especially in a language like PHP. It&#x27;s easy to convert a series of 10 if statements into one while loop by leveraging call_user_func and deterministic method names. The resulting while statement is infinitely more complex than the if statements and reduces the benefits of using an IDE. So unless your CC algorithm treats this kind of programming as wildly complex, then it&#x27;s not giving you a true complexity value (in fact, it&#x27;s actually lying to you).<p>% of non-static methods: Unless this metric also includes singleton patterns, then it&#x27;s useless. Foo::bar() is no different than Foo::getInstance()-&gt;bar() or (new Foo())-&gt;bar(). Also, in PHP-land, static methods are considered acceptable, as long as they have no side-effects or use static variables.<p>So I think the author is genuinely wasting his time capturing and optimizing for these metrics, because I don&#x27;t think they provide any meaningful improvement to the product.
评论 #13415670 未加载
Avalaxyover 8 years ago
I&#x27;ve never worked with these frameworks since I don&#x27;t use PHP anymore, but I must say I&#x27;m quite impressed by the average LOC per function and percentage of static function. Especially Laravel surprised me... The longest method is only 13 LOC? Wow!
评论 #13365081 未加载
pan69over 8 years ago
Not to sure how &quot;fair&quot; this comparison is. You see, both Symfony and Zend Framework are mostly components, doing kinda low-level-ish things. It probably means that overall their complexity is probably higher.<p>A more fair comparison would be to compare Lavavel against both the Symfony HttpKernel component (which is the framework part of Symfony) and the Zend MVC module (which is framework part of Zend Framework). But then again, it&#x27;s probably not that straight forward.<p>I mean, when testing Laravel the Symfony HttpFoundation component is left out but when testing Symfony it&#x27;s included, not really fair..
grimmdudeover 8 years ago
Would be nice to put this data in a chart.