Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Checking the Code Complexity of your App
Jan 11, 2017 @ 11:52:58

On the Laravel News site there's an article posted showing you how to determine the complexity of your application using the phploc tool from Sebastian Bergmann.

Yesterday, Taylor made a post comparing the code complexity between Laravel and other frameworks. The tool he used to generate these reports is called phploc and it’s very easy to run on your own code base.

I decided as a means of comparison I would run that on the codebase for this site and just see what the results are.

The tutorial walks you through the installation of the tool (as a globally installed Composer package), how to execute it and what the results look like. These results include a lot of data including:

  • Average Class Length
  • Average Complexity per LLOC
  • (Use of) Global Constants
  • (Number of) Namespaces

phploc is useful for getting the overall numbers but he wanted something a bit more specific. For that he chose the PhpMetrics package that allows for deeper introspection into files and classes in your code to locate the complexity and find spots for refactoring.

tagged: code complexity tool phploc phpmetrics example composer tutorial

Link: https://laravel-news.com/code-complexity-tools

SitePoint PHP Blog:
Visualize Your Code’s Quality with PhpMetrics
Dec 26, 2014 @ 12:48:31

The SitePoint PHP blog has a recent tutorial showing how to use PhpMetrics to visualize your application and the quality of its code.

We had been looking into code quality checking tools for a while here on SitePoint – most recently in a series on Jenkins, but none of those could do what a project I’ve only recently found out about can. PhpMetrics uses D3 and some sophisticated analysis algorithms to scan your application’s code and output intricate reports about it.

He walks you through the install (via Composer) and how to clone two example projects, Laravel and Symfony, to evaluate. He includes the command line to run the evaluation and plenty of screenshots showing the results for things like:

  • Cyclomatic complexity
  • Abstractness
  • Maintainability
  • Code density

He uses the results from these two projects in his examples and, at the end of the post, summarizes and compares the results it produced.

tagged: code quality metrics phpmetrics visualize tutorial

Link: http://www.sitepoint.com/visualize-codes-quality-phpmetrics/

Peter Aba:
phpmetrics of popular php projects
Sep 15, 2014 @ 10:11:01

Peter Aba has put together a a set of visualizations around the popularity of various PHP projects using the phpmetrics tool. He decided to run it against several projects he knows of and share the results.

I came across a new tool called phpmetrics. It can be used for, what a surprise, calculating and displaying metrics for php. I fell in love with this cute little tool in an instance and decided to run it on some php projects that I consider important. I’m aware of the fact that the list is currently far from complete, but it’s probably still worth a look. I especially love the “maintenability” (sic!) reports, I find those big red spots just as disgusting as I find ugly code the same.

He's broken it up into a few different sections with lots of different projects under each:

  • Frameworks
  • CMS
  • E-commerce
  • Development tools

There's also an "Other" (and "Backfire") category that contains the results for the results of phpmetrics itself. He also includes a few issues he ran across during the processing of the metrics, some with the phpmetrics tool itself and some with the libraries themselves.

tagged: metrics popular projects phpmetrics results visualization

Link: https://peteraba.com/blog/phpmetrics-of-popular-projects/