Skip to main content

count lines in a PHP project



I'm just curious. Do you know any tool which can count all the code lines from a PHP project?





Many thx!



Source: Tips4all

Comments

  1. On a POSIX operating system (e.g. Linux or OS X) you can write the following into your Bash shell:

    wc -l `find . -iname "*.php"`


    This will count the lines in all php-files in the current directory and also subdirectories. (Note that those single 'quotes' are backticks, not actual single quotes)

    ReplyDelete
  2. SLOCCount is an awesome tool that produces a line-count report for a large number of languages. It also goes further by producing other, related statistics such as expected developer cost.

    Here's an example:

    $ sloccount .
    Creating filelist for experimental
    Creating filelist for prototype
    Categorizing files.
    Finding a working MD5 command....
    Found a working MD5 command.
    Computing results.


    SLOC Directory SLOC-by-Language (Sorted)
    10965 experimental cpp=5116,ansic=4976,python=873
    832 prototype cpp=518,tcl=314


    Totals grouped by language (dominant language first):
    cpp: 5634 (47.76%)
    ansic: 4976 (42.18%)
    python: 873 (7.40%)
    tcl: 314 (2.66%)




    Total Physical Source Lines of Code (SLOC) = 11,797
    Development Effort Estimate, Person-Years (Person-Months) = 2.67 (32.03)
    (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
    Schedule Estimate, Years (Months) = 0.78 (9.33)
    (Basic COCOMO model, Months = 2.5 * (person-months**0.38))
    Estimated Average Number of Developers (Effort/Schedule) = 3.43
    Total Estimated Cost to Develop = $ 360,580
    (average salary = $56,286/year, overhead = 2.40).
    SLOCCount, Copyright (C) 2001-2004 David A. Wheeler
    SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL.
    SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to
    redistribute it under certain conditions as specified by the GNU GPL license;
    see the documentation for details.
    Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."

    ReplyDelete
  3. Unfortunately, SLOCCount is a bit long in the tooth and a pain in the neck for PHP projects, particularly ones that have a nested vendor directory you don't want counted. Also, it emits a warning for every PHP file that doesn't have a closing tag (which should be all of them if you aren't mixing HTML and PHP).

    CLOC is a more modern alternative that does everything SLOCCount does, but also supports an --exclude-dir option and it doesn't suffer from the aforementioned close tag problem. It also emits a SQLite database that you can extract some pretty advanced metrics from.

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex