How to get lines of code in PHP with PHPLoc via CLI or using Docker

This video shows how to get the lines of code in a PHP application by using PHPLoc from the command line or using Docker. PHPLoc is a command line application to generate a small but useful report. Adam Culp will show how to use it from a Docker Container using a Docker Image he created. PHPLoc demonstrated on the Concrete5 CMS codebase.

Key Topics:

  • Why find the lines of code
  • PHPLoc is an application to find the lines of code in PHP
  • Different methods to use PHPLoc
  • How to use a Docker image to run PHPLoc
  • Comments as a code smell

Associated Links:
https://en.wikipedia.org/wiki/Code_smell – Code smells explained
https://www.docker.com/get-started – The place for developers to start with Docker
https://hub.docker.com/r/adamculp/php-code-quality – link to the image used to build the Docker container used in this video
https://github.com/sebastianbergmann/phploc – location of the PHPLoc tool
https://www.concrete5.org/ – Concrete5 CMS code I’m using in this video

What motivates us?

This animated video from RSA features Dan Pink, a well known speech writer for Al Gore and Robert Reich, has spoken at TED (YouTube), and wrote a book called “Drive: The Surprising Truth About What Motivates Us”, does an awesome job of breaking down what motivates people doing complex tasks.  It is short and easy to “get” presentation with very awesome animation. (I wish I could draw like that.)

I think some may be surprised by the message.

Great time at php|tek 2012

On May 21st, 2012 I set out on a journey to my once annual PHP related conference. I have limited myself to a single conference each year and generally work the expenses and time into my employment contract. Most companies are willing to sponsor employees going to a conference, as long as it will benefit them in some way and as long as you get it approved from the beginning of your employment. (Otherwise they “perceive” it as an expense and not an investment to gain an employee.)

I arrived early in the morning rather than later in the day (there were no flights in the middle) because I wanted to ensure I had time to network and socialize prior to the tutorials the following day. For past conferences I always enjoyed them and learned a bunch, but never really socialized much. I was the wall flower quiet person sitting in the front latching onto every word of the speakers, but then didn’t really talk much after.  This year I wanted to make it different.

Why the difference? A couple of years ago (due to events I will cover elsewhere) I decided to help South Florida enter the PHP community and grow into a place where companies could find PHP developers, and where PHP developers would enjoy a thriving community. So I started the South Florida PHP Users Group which has grown to around 270 members. In the process I learned to gain the most from any event or training through an added social aspect and that realization washed over into how I experienced Tek12.

Tek12 was very social…more social than I remember on previous times I attended. It seemed like everywhere I looked there was a group talking, and laughing.  And each group was very approachable or outright invited bystanders to participate.  Plus the groups constantly changed, so there were no “clicks” where the same people were always together.  Everyone seemed to flow from one group to another and contribute to each conversation.  I also felt very comfortable walking right up to others and simply asking a question. (Something I think most are intimidated to do.)  So I learned a bunch, and had a great time finding answers to questions I’ve had for some time.

I loved the achievement patch idea, and feel it helped by gently forcing everyone to talk to the sponsors and each other. It wasn’t like entering a large hall full of sponsor tables where you quickly passed a table grabbing “swag” and avoiding an uncomfortable product spiel on something of no interest. The php|tek crew did a good job of bringing sponsors who are relevant to current developer needs.  Not only did I learn from some of them, but I also found some services I can really use.  And I did manage to collect EVERY patch, plus one extra from Mashery for building a quick application using one of their APIs. (It is the white patch.)

Of course the sessions at the conference were wonderful with lots of great speakers. It took me a few days for my brain to catch up and actually digest the contents and topics I saw. I am still trying to work through some of them. The people who decided which talks get through the screening process did a great job of ensuring we had a good list of topics, and kept them relevant to current trends.

I also took advantage of the Engine Yard Jaunt sponsored by Engine Yard on Friday night after the conference.  It was a great way to see some sites in the city, and spend more time with old and new friends in the PHP community.  There was great pizza at Giordano’s, a tour of Skydeck Chicago, and then some night life events. (My wife and son were arriving at the airport to spend the weekend with me in Chicago, so I didn’t continue on to the club portion of the trip, but I am sure everyone had a great time.)

Of course no trip would be complete without a short jaunt with the family on a beautiful sunny day.  So on Saturday and Sunday we headed out and saw a lot more of the city, which will be posted on my more “family” oriented outlets.