Simple Project Profiling With PHPLoc
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).
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.