Framework Porn

(No, not really porn. Totally SFW) 

Today Taylor Ottwell, creator of the Laravel framework, posted the Framework Code Complexity Comparison. For those not familiar with “Cyclomatic Complexity” here’s the Wikipedia page Cyclomatic Complexity. Briefly, “Cyclomatic Complexity is a software metric (measurement), used to indicate the complexity of a program.”

While Taylor’s post gives you the complete breakdown, here are the average method complexity scores for each framework tested. (Lower is better)

Laravel 1.62
Symfony 1.88
Slim 2.40
Zend 2.76
CakePHP 3.30

Taylor also compares Laravel’s Eloquent ORM to Doctrine. Since I think ORMs are evil, I won’t list those scores here. You can read them on the blog post though.

Cyclomatic Scores are not the end-all, be-all comparison of frameworks. They are however an interesting fact to consider when looking at a framework. Less complex framework code usually means less complex application code.

If you are interested in testing your own project’s Cyclomatic Complexity score, you will need PHP Mess Detector installed and up and running. Check out Leonid Mamchenkov’s recent post Quick and Easy Introduction into PHP Mess Detector (PHPMD)” as it’s the best instructions I’ve seen for getting PHPMD up and running quickly.

You can also use Sebastian Bergmann’s phploc to calculate Cyclomatic Complexity. (It supports PHP 7.1) To do that, use composer to either require it in your project or require it globally and then from your project’s root directory execute:

phploc ./ --exclude vendor/

4 comments on “Framework Porn

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>