php

Debugging API Requests in the v2 Google PHP SDK

In a previous article we looked at using the new v2 Google PHP SDK to work with exporting Google Sheets. In working on that article I ran across some interesting side-effects of the middleware model. I’d like to mention some of those side-effects. First, let’s talk about what middleware is.

Read more …

Exporting Google Sheets in the v2 PHP SDK (google/apiclient v2.0.0-RC4)

I’ve been playing around with the new google/apiclient (v2.0.0) for use with Google Drive and ran into some issues figuring out how to make use of the ability to export, for example, a Google Sheet as a CSV or Excel spreadsheet.

Read more …

Dependency Injection

@ircmaxell has a great explanation of the concept of dependency injection (DI). I won’t even link to anything else about the concept because any Wikipedia entry would just confuse the issue. Watch this video first, then go Googling.

Read more …

20 Years of PHP

This is my contribution to the #20yearsofphp story telling happening today on Twitter. I’m coming to this a bit late, but I thought I should add my part.

In 2005, I had just graduated with a B.A. in Mathematics and Philosophy from a small liberal arts college in the midwest, had been working in the IT department there since about 2004, and was rather tired of the same old routine of fixing persistent printer problems and troubleshooting roaming profile issues in a Win2k/Novell environment.

For a couple years, one of the workstations in the office doubled as a web-server that hosted a key/core management web-application for our physical plant department. It was served via IIS using ASP backed with an MS Access database. All it did was keep track of which doors had which cores and what personnel had which keys.

The original developer had since moved on to other things, so we were looking for a way to replace the fragile setup. The director of IT (he’s still there) made a random comment (joke really, in hindsight) about needing to look into MySQL and maybe PHP.

So I began Googling.

As it became clear to me what really could be done with PHP (and with what ease!), my imagination began to grow as well. To this point my experience with programming was a boring world of for loops and pointer arithmetic (I blame the varous “teach yourself C in 24 hours” books for making it so boring.)

What turned this from a curiosity into something that could actually solve a problem, was figuring out how to authenticate users via LDAP. PHP’s ldap extension made this easy. Learning this made me feel I could do anything.

The original code I wrote was atrocious.

I had a single admin.php script which included a rather epic if-then-else construct branching based on an “action” request parameter (as was common in the day). Much SQL and not too little HTML was all embedded within this behemoth script. This was my first PHP application, and the last to utilize such a routing mechanism.

Within a year I wanted to write version 2.0 of the application. I had learned about Smarty templates and just enough MVC to be dangerous. This led me down the path to more MVC (and patterns! of course) and the important lessons of separation of concerns. My voracious apetite for learning and fervent desire to Do it Right™ caused version 2.0 to suffer from what I now see was a case of the second-system syndrome.

It took nearly two years to finish.

When it finally did ship, I had moved on from my employment at that institution, and had nearly finished a year of graduate school in the mathematics department at the University of Kansas.

I never really finished that year of graduate school. Turns out…I’m not that great at math. Instead I began to look at ways of getting full-time employment in tech, but not in programming.

I began the process of becoming recertified as a CCNA with a goal of ultimately becoming a CCIE. I even went so far as to trawl eBay looking for old Cisco routers and switches to build my networking lab. (I’ve since gotten rid of all of the equipment: two 2501 routers, a couple 2600 series routers, a T1 modem, and a couple of Catalyst switches—along with all the attendant cabling). This led me to apply for a position with a company in Wisconsin called Berbee Information Networks—since acquired by CDW. I went through a few phone interviews and was flown out to one of their offices in Madison, WI for an on-site interview. Two weeks later they informed me I didn’t get the job. The same day, I had an interview for my first full-time programming gig in Wichita, KS at a small tech company—since acquired by CybertronPC.

There I came into contact with the Zend Framework 1.0.x and started reading programming blogs including Rob, Matthew, Pádraic, Jani, and Jeff to name a few. At this job I did mostly internal-facing apps such as systems for managing ER patient chart coding and billing and torque tool calibration/certification tracking. After almost four years, though, I was looking for new challenges and to be nearer to members of my family living on the east coast. That brought me to my current position at a small university in the Shenandoah Valley in Virginia.

The PHP community has been good to me.

Before PHP I spent many hours during high school learning C/C++, but PHP was the first language that let me really do something without a lot of frustration. It was the first language that taught me patience when developing and gave me a real job. Now that I’ve been programming in PHP for 10 years (7 years full-time), it’s more than once per week that I want a more strongly typed language, but I’m glad PHP was flexible enough for a beginner to get some work done without a lot of hassle.

I’m excited at what the future has to offer for PHP 7.

Read more …

Memory Leak Behavior with ArrayIterator, SplHeap, and SplDoublyLinkedlist in PHP 5.{3,4,5,6}

Since PHP 5.3 it has been possible for memory occupied by objects having cyclic references to be reclaimed via the new garbage collection feature. However, there is a case in which the garbage collector does not appear to be able to reclaim memory.

Read more …