Code Info

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dajawu
Forum Commoner
Posts: 59
Joined: Fri May 23, 2008 10:16 am

Code Info

Post by dajawu »

Is there an easy way, a function perhaps that will list lines of code on a PHP file and maybee even list lines of code through out your whole website? Like it could list that there are 13PHP file totaling 2500 lines of code?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Code Info

Post by jaoudestudios »

You could scan through the directory and then read every php file into a string or array, then keep appending a variable until the loop is finished then display to screen or output to a file.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Code Info

Post by Benjamin »

I was going to write one of these when I got bored enough, but it appears someone already did.

http://webmaster-forums.code-head.com/s ... .php?t=363
dajawu
Forum Commoner
Posts: 59
Joined: Fri May 23, 2008 10:16 am

Re: Code Info

Post by dajawu »

Awsome thanks!
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Code Info

Post by alex.barylski »

I wrote such a utility...however I had intentions on making it a framework for more advanced metrics calculations...

It doesn't just count physical lines but SLOC instead. I use it to keep track of files which grow wildly large so I can quickly pickout which files are in need of a refactoring.

One day I plan to extend it into a full blown metrics tool...one day. :P
Attachments
PHP Metrics.zip
(6.67 KiB) Downloaded 52 times
Post Reply