I’m optimizing my Meta Box plugin and I need a way to measure the project’s statistics such as complexity and maintainability. After searching on Google, I found PHPMetrics, a wonderful project that can help me understand lots of key metrics for a PHP project. The result is displayed in a HTML report with some graphs and table of metrics which are very easy to understand. I tried using it with the Meta Box plugin and here is the result:

Meta Box plugin metrics
Meta Box plugin metrics

The bubbles of the report is an overview of the maintainability and complexity of the project, where:

  • The number of bubbles simply are the number of classes. It does not mean the project is hard to maintain.
  • The color of bubbles / metrics means the maintainability of the class / project: read = hard, yellow = acceptable but careful, red = hard
  • The size of bubbles means the complexity of the class, smaller is better

In the table, there are some key metrics:

  • lloc: Number of logical lines of code (without comments), less is better.
  • length: Halstead metric of the project, less is better
  • MI: Maintainability index is based on Halstead’s metrics, LOC and Cyclomatic complexity number, more is better.

To understand other metrics, please read the explanation at the PHPMetrics homepage.

So, my Meta Box plugin looks not too complicated and easy to maintain which is quite good to me. In the next versions, my developers and I will work hard on refactoring the plugin, make it smaller and less logic.

I also went further to compare the Meta Box plugin with CMB2, a very similar plugin and here is the result of CMB2:

CMB2 metrics
CMB2 metrics

Some notes:

  • The CMB2 uses fewer classes than Meta Box plugin (this is obvious because Meta Box provides more field types than CMB2, where each field type is a class)
  • Although fewer classes, CMB2 seems a little bit more complicated than Meta Box in all metrics (size of bubbles, color of bubbles, lloc, length and MI)

And here is the result of Advanced Custom Fields, the most popular plugin for custom fields:

ACF metrics
ACF metrics

It’s easy to see that ACF is more complicated and harder to maintain than both Meta Box and CMB2. It’s quite obvious since ACF provides UI for users to add and manage custom fields, which requires a lot of work and logic.

I also wanted to check the statistics of WordPress to see how good it is. Unfortunately, the result doesn’t look good:

WordPress metrics
WordPress metrics

Hard to maintain, a lot! Here is the full report.

You can find the metrics of other PHP frameworks as well. I’m very surprised about Laravel and Fuel frameworks, they’re amazingly good!

So, if you want to understand your project and keep the development in a good direction, PHPMetrics is a must have tool. Have fun coding and let me know what you think about it in the comments.


  1. Hi. Sounds good for meta box fan :)
    Note the WordPress test was passed almost 2 years ago.
    It would be good to have more serialized data (fields with multiple values).
    Moreover with CMB2 fields can be used with Users, and it s possible to display metabox forms on the front-end : chalenge ? :)

    Thanks for your amazing work!

Leave a Reply