Skip to main content


phploc is cool tool, by Sebastian Bergmann, to check the size of your php project. You can install it with PEAR. The short version of the installation goes like this:
// add PEAR channel
user@host ~ % pear channel-discover
// install phploc
user@host ~ % pear install phpunit/phploc
// run
user@host ~ % phploc /path/to/your/project/code/folder

For more detailed instructions and system requirements, here is the link.

Now we are going to play a little honesty game:
Run the tool against your php project library code
[user@host] phploc ./library/Zend/
phploc 1.0.0 by Sebastian Bergmann.
Directories: 285
Files: 1372
Lines of Code (LOC): 275436
Comment Lines of Code (CLOC): 130251
Non-Comment Lines of Code (NCLOC): 145185
Interfaces: 53
Classes: 1321
Functions/Methods: 9170

Run the tool against your php project own code:
[user@host] phploc ./my_application/my_modules/
phploc 1.0.0 by Sebastian Bergmann.
Directories: 30
Files: 85
Lines of Code (LOC): 6644
Comment Lines of Code (CLOC): 580
Non-Comment Lines of Code (NCLOC): 6064
Interfaces: 0
Classes: 94
Functions/Methods: 284

Now calculate the percentage of your code vs. your favorite framework library codepercentage = my_code_NCLOC/my_library_NCLOC*100in my case the result is 4.17% !!! :) :) How about in your project?


Popular posts from this blog

Enable pgpass under Windows 7

Last year I have written a post about enabling pgpass under Windows XP . Today I repeated the procedure for Windows 7. Basically everything worked as before, with the following exception - the APPDATA directory in Win 7 is different. What I did first was to check the name of the user running PostgreSQL server process. Then log in as that user and find out where is the APPDATA directory for that user. echo %APPDATA% From that point on, just follow the instructions in the previous post. Good luck!

Numeric Drop-down With PHP ranges

Here is an easy way to generate form numeric drop-down with ranges. $form = new Zend_Form(); $ranges = array( range(1, 20, 1) , range(30, 100, 10) , range(200, 1000, 100) ); $a = array(); foreach ( $ranges as $range ) { foreach ( $range as $r ) { $a[$r] = $r; } } $form->addElement('select', 'quantity', array( 'label' => 'Quantity' , 'required' => false , 'class' => 'form-control' , 'multiOptions' => array( '' => '--Select--' ) + $a )); Please note that the ranges are with different steps. Here is the result: