Skip to content

Celebrating 20 years of PHP

elephpants-512

Dear Reader,

Here is my PHP story.

In 1997, I built my first web based application. When completed it was running on 2 Microsoft Windows servers and powered by ASP (Classic) and SQL Server 6.5. It was around this time that Microsoft decided that if you wanted to use SQL Server on the web, you have to purchase a special web license that was very expensive. This actually was a concession for them because originally they stated that you have to have a license for each person who used your website.  I’m pretty sure they didn’t think that one through, thus the back-peddling and the new Microsoft tax on the web.

I had already purchased 2 licenses for Windows Server and one license for SQL Server and the little company I was building this for could not afford the $15,000 for the new licenses and upgrades. No new hardware and no new functionality, just Microsoft sticking a spigot into our bank account and opening it.

So in 1999, I started looking around for alternatives. I had heard of this new language called PHP and that it was open source. I wasn’t really sure what that meant at the time but figured that it couldn’t cost any MORE than Microsoft, so I started investigating. It turns out that it was gonna cost me a LOT less. No, things weren’t free, but with a little creativity and with the help of a lot of open source software, I was able to rebuild the entire application using PHP.

Not counting what they paid me as a programmer, the new system cost $4,500, that was the price of a shiny new server. All of the software I used was open source.

  • RedHat Linux (Remember RPM hell?) :)
  • Apache
  • PHP
  • MySQL (back when it WAS MySQL)
  • Shoutcast (I has streaming audio way back then)
  •  and a few dozen other packages I can’t recall now

PHP was the catalyst. Since I built that system, I’ve toyed with other languages. I’ve even become proficient enough with JavaScript to get web pages working. However, I’ve never seen the appeal of JavaScript on the server. PHP does the tasks I need done without an issue. (FTR, I felt the same way about Server Side JS the first time I saw it back in ’97ish? What? You thought this was a NEW idea? :) )

PHP is a solid language, it has a great manual, and an awesome community. Those three things raise the bar for switching pretty high.

Thank you to everyone who has contributed to PHP

  • Thank you to all of the core contributors
  • Thank you to all the people who work on the manual
  • Thank you to everyone who runs a PHP User Group
  •  Thank you to everyone who contributes to the PHP community

I owe so many people so much that I can’t even begin to start naming names. In the spirit of the PHP community, I am now, and will continue to, pay it forward each and every day.

Until next time,
I <3 |<
=C=

My latest book, “Iterating PHP Iterators”

PrintDear Reader,

I am happy to announce the latest in my “Learn One Thing” books series, “Iterating PHP Iterators”.  My friend Christopher (@assertchris) Pitt summed it up best in his review of the book.

This is a great book for beginners and intermediate developers. It’s a comprehensive introduction to iterators and some of the implementations that ship with the SPL.

That is exactly what I was going for, a book for beginner and intermediate developers. I hope it helps someone along their journey.

Early Adopters Save

As is my tradition, this book is available to early adopters at a lower rate. Until April 11th, 2015, this book is available for $5.99. After that it goes to it’s retail price of $9.95.

Back Story

Each book has a story. This one almost didn’t happen. I started this book over a year ago. I wrote about 75% of it and then got distracted with another project. I set it aside and forgot about it. I’ve even written another book, “Culture of Respect” between when I started this one and finished it.

While I was writing “Culture of Respect” I noticed it in Dropbox and remembered that I never finished it. So in Feb of this year, I picked it back up, finished it, fleshed out the code, polished it up, and pushed the button.

Thank you

I have to say a huge thank you to Christopher Pitt.  I sent him a copy for review, he sent me back 12 PRs with formatting issues. Thank you Chris for embodying the PHP Community’s “Pay It Forward” attitude. I hope to be able to repay the favor one day.

Until next time,
I <3 |<
=C=

Reordering Style Sheets in WordPress

Dear Reader,

10/09/2019
Updated the code. The original code would not work properly if the array had any missing keys. (e.g. a style sheet was unenqueued). To fix this, I use array_values() to remove any gaps in the index before processing it.

The Lovely and Talented Kathy is responsible for how all our websites look here at EICC. If it looks good, she did it, if it doesn’t look good, I’ve obviously been mucking around in it and she will eventually fix it. Occasionally, she has need for my particular skills. Compared to her artistic pen strokes, my code in a sledge hammer, but when dealing with WordPress, sometimes a sledgehammer is what is needed.

With Stylesheets, order matters

I’ll never understand why theme and plugin authors don’t understand this one simple idea. User stylesheets should be loaded last. They should be able to override anything and everything because the end designer, not you the theme or plugin designer know what is best. Still there are some that simply insist that the the user’s stylesheet not be the last thing enqueued to load. I’ve grown tired of fixing this on each and ever site we have by digging into the functions.php of the last site we built to figure out how I did it. So I’m blogging my solution.

Hacking WP_Styles

What I found is that WordPress has a wonderful object called WP_Styles When theme and plugin authors enqueue styles, it adds them to this object. (For fun one day drop a print_r($wp_styles) into your functions.php. There is a LOT of stuff in there.)

One of the properties that I noticed when studying WP_Styles was the queue array. Looking at it, this was a list of the tag ids of the stylesheets to be queued. Examining the source of the page that was output, it was obvious that they were in the same order as the stylesheets were output. So I decided to test and see if the order of the array controlled the output order. Sure enough it did. So from now on, this little piece of code lives in the functions.php of every child theme she creates.

The Code

To use this, just identify the IDs of the style sheets you want to move, and add them to the $keys array.

1
2
<link rel='stylesheet' id='bootstrap-basic-style-css'  href='/style.css' type='text/css'/>
<link rel='stylesheet' id='it-exchange-child-theme-css-css'  href='/style.css' type='text/css' />

The stylesheets above are the two I have listed in the function below. Notice that each is appended with an additional -css. Make sure you do not put that in the code below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function cal_adjuststylesheets() {
  global $wp_styles;
 
  $keys=[
    'bootstrap-basic-style',
    'it-exchange-child-theme-css'
  ];
  $wp_styles->queue = array_values($wp_styles->queue);
 
  foreach($keys as $currentKey) {
    $keyToSplice = array_search($currentKey,$wp_styles->queue);
      if ($keyToSplice!==false && !is_null($keyToSplice)) {
        $elementToMove = array_splice($wp_styles->queue,$keyToSplice,1);
        $wp_styles->queue[] = $elementToMove[0];
      }
  }
}
 
add_action( 'wp_print_styles', 'cal_adjuststylesheets',99);

The last line calls this code just before the stylesheets are printed. Make sure you put that in there or WordPress will ignore it.  Order is important as the style sheets you specify will float to the bottom of the list but be in the order that you have specified.

 

WrapUp

Drop that little snippet in your functions.php and you never have to worry about your stylesheet being listed before the one you want to override.

Until next time,
I <3 |<
=C=

Airfare and Two Nights in the Hotel

Dear Reader,

This is a rant, feel free to skip it. Also, I am talking about myself in this rant. There are a lot of other speakers who fall into this bucket with me, but everything I’m saying here applies to me.

The Problem

PHP conferences are changing very slowly, and not in a way that I like. I blame myself. As a frequent speaker I am getting lazy. I get caught up in the excitement of the CfP, I write up 5-10 abstracts and shotgun them into the CfP system hoping that something hits the mark. I’ve not actually written these talks. In most cases, I’m pretty sure I can get 45 minutes on the topic, but I don’t know for sure because I’ve not bothered to write it yet. Adam Culp talks about this very thing in his post “Are Conference Talks Getting Too Soft?“.

The problem is that I’ve lost my focus. My focus should be the cool thing am I dying to share with other developers.  Instead, I’m chasing that “Airfare and two nights in the hotel”. I know this because my focus is writing abstracts. That and abstracts that don’t get accepted, I never bother to write. This is backwards. I should be so excited about sharing something that I write it up anyhow. I should blog about it, prepare the slides, and contact my local PHP User Group and see if they will allow me to present it. The local PUG is the lifeblood of our great community. It is important to me that I support them first, then conferences.

Being the Change I Want to See

To help me refocus, I have set myself two goals for 2015.

  1. I want to present at 5 local PHP User Groups in 2015.
  2. I will not submit to a conference any talk that I have not written and presented at a local event. (The exception I am making is keynotes because some conferences I speak at ask me to write a new keynote.)

I am refocusing my speaking efforts on talking to the local level. There are probably 5-6 PUGs I can reach by car and can speak at. So as I come up with an idea for a talk, I will first submit it to any and all PUGs that will have me. Then, if that talk seems solid and is helping people, I will submit it to conferences.

This is not to say that I won’t be submitting talks to major conferences, but I will not be submitting talks that I’ve not already written and presented at least once locally.

Looking to Others for Help As Well

I am privileged enough to be asked to help score talks for several of different PHP conferences. in 2015, I will start be a lot more picky in the talks for which I vote. I will look for – and up vote – talks where the presenter makes a note that they have given this talk at a local event already.

Wrap Up

So next time you are starting at a CfP, don’t brainstorm a lot of talks, submit them all and write the ones that get accepted. Look at the talks you’ve done for your local PUG, and submit them. You know they exist, you know they work, and you know you are supporting your local PUG.

Wouldn’t it be great if PHP User Group leaders had to start scheduling talks 6 months out? I’ll take that problem any day of the week. :)

Until next time,
I <3 |<
=C=

p.s. If you are considering writing a talk and need some help with your abstract, let me help.

Five influencers you should thank this year for making the PHP community so awesome

Thank You by Adi RespatiDear Reader,

It is no surprise to anyone who has talked to me for more than five minutes that I think the PHP community is the most vibrant and engaging developer community out there. So as we approach the end of the year, I am going to list out the influencers that help keep this community at the top. These are the people that you need to seek out and thank because without them, the PHP community would not be what it is today.

5: Core Developers

Let’s face it, without PHP, there would be no PHP community. So the influencer you need to reach out to and thank is any person you know or know of that has contributed to the Core. I’m going to also include all those who contribute to the manual. PHP is a great language and it has a great manual.

4: User Group Leaders

User Group leaders are awesome because every month they organize their small corner of the community. They do this because they believe in the community. It is largely a thankless job. Rarely do people stop to say thank you when it goes great. Trust me though, if something goes wrong, they hear about it. Reach out to your local PHP User Group leader and thank them for all they do for the PHP community.

3: Conference Organizers

If you have never organized a conference then you have no idea how much work it is to put one on. Whether it is a commercial conference or a community conference, the time and effort is largely the same. PHP is blessed with some great conferences both commercial and community. Take some time this week to reach out to those who organize your favorite conference and tell them how much you appreciate it. Let them know if something you learned at their conference had a positive effect  on your life.

2:Conference Speakers, Bloggers, and Teachers

Preparing a technical talk, tutorial length blog post, or a class that teaches something meaningful is a difficult process. Many people will spend weeks or even a month working on a single talk that is over in 60 minutes. These people do this largely to help others learn. They share what they have learned so that other developers can understand. If you know someone who regularly speaks, blogs, or teaches in the PHP community, reach out to them and tell them thank you.

1:Any developer using PHP

All of us together make up the PHP community. If you write code in PHP – for your day job, for your side projects, for whatever – you are part of the PHP community. Instead of urging you to say thank you to other developers though, I am going to take this time to say thank you to you.

If you write code in PHP, thank you.

  • Thank you for choosing PHP
  • Thank you for using it to create cool things
  • Thank you for helping make PHP power over half of the web.

Wrap Up

If you were looking for a list of 5 specific people to follow/thank/put on a pedestal, that’s not what I do. The PHP community is about all of us, not an elite few.

As you are winding down your 2014 and thinking back, think back to the PHP community members that have had a positive impact on your life and/or career and reach out to them personally to say thank you.  Make sure though you take time to reflect on the PHP community as a whole. Take a moment and tweet or Facebook a thanks to the entire community for being such a welcoming and awesome community. Then go get involved in your local PUG.

 

Until next time,
I <3 |<
=C=

 

Photo Credit:

Thank you by Adi Respati