Made of Everything You're Not

If you're a stalker I'd prefer if you didn't kill me. Thanks.
  • Home
  • Projects
  • Portfolio
  • Resume

Posts Tagged ‘phploc’

Simple Project Profiling With PHPLoc

Posted in Brain Dump, Programming on November 24th, 2009 by Eric Lamb – 1 Comment

One of the most natural things to do while being an obsessive programmer is focusing on the minutia. Not only do our projects have to perform and function to our standards but they also have to be structured “just so” with just the right comment style and just the right indentation to space ratio (4 of course!). Point being that, for me, it’s ridiculously easy to spend time and energy focusing on, what amounts to in the end, as trivial. I was reminded of this while playing around with the latest release of PHPLoc (1.40).

Photo: Grahambones

Photo: Grahambones

PHPLoc is a project by Sebastian Berman that measures the size of a PHP project. In a nutshell PHPLoc is a project analyzer that shows details like amount of classes, files, directories and total Lines Of Code (PHPLoc get it?) to name a few features. It’s ran from the command line and I had no issue getting it to work on Windows (huge plus for quality IMHO).

According to the Git repository:

phploc is a tool for quickly measuring the size of a PHP project.

The goal of phploc is not not to replace more sophisticated tools such as phpcs, pdepend, or phpmd, but rather to provide an alternative to them when you just need to get a quick understanding of a project’s size.

PHPLoc works as a PEAR module (requires PEAR installer version 1.8.1 at least) and as such is really easy to install. There’s some great instructions on the Git site that I had zero issues with (outside of having to update PEAR) so I won’t go into detail here.

Here’s an example of the output when ran against a Zend Framework 1.9 distribution:

C:\php>phploc --count-tests C:\ProjectFiles\ZF
phploc 1.4.0 by Sebastian Bergmann.
 
Directories:                                        393
Files:                                             1856
 
Lines of Code (LOC):                             372292
  Cyclomatic Complexity / Lines of Code:           0.11
Comment Lines of Code (CLOC):                    173793
Non-Comment Lines of Code (NCLOC):               198499
 
Namespaces:                                           0
Interfaces:                                          94
Classes:                                           1758
  Abstract:                                         155 (8.82%)
  Concrete:                                        1603 (91.18%)
  Lines of Code / Number of Classes:                167
Methods:                                          12377
  Scope:
    Non-Static:                                   11517 (93.05%)
    Static:                                         860 (6.95%)
  Visibility:
    Public:                                        9886 (79.87%)
    Non-Public:                                    2491 (20.13%)
  Lines of Code / Number of Methods:                 23
  Cyclomatic Complexity / Number of Methods:       2.78
 
Anonymous Functions:                                  0
Functions:                                            0
 
Constants:                                         3361
  Global constants:                                   1
  Class constants:                                 3360
 
Tests:
  Classes:                                            2
  Methods:                                            0

As you can see, PHPLoc gives some really nice insight into a project. I have to admit I’m more interested in the OCD satisfaction than the practical reasons but it’s still cool. Definitely check it out if you’re looking to get some interesting though completely trivial information about your project.

Bookmark and Share
  • Subscribe: Entries | Comments
  • About Me

    Email Email
    Twitter Twitter
    310.739.3322
  • Categories

    • Brain Dump
    • Business
    • Code
    • IT
    • Programming
    • Rant
    • Servers
  • Archives

    • October 2011
    • August 2011
    • July 2011
    • June 2011
    • May 2011
    • April 2011
    • March 2011
    • February 2011
    • January 2011
    • December 2010
    • November 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008

Copyright © 2008 - 2012 Eric Lamb - All rights reserved