Skip to content

Everything changes…even conferences

Dear Reader,

“Change is the only constant in life.”
— Heraclitus

I’ve been around tech conferences for a long time now. I’ve seen conferences come and go. The more I look at tech conferences though, the more I realize that old Heraclitus was correct. The only constant in the tech conference sphere is that it is constantly changing…and that’s a good thing.

When I started working with PHP conferences There were only a handful of speakers and they were at almost every conference. All of us realized that this wasn’t ideal, but – at least in the PHP community – we had to grow our own talent base speaker-wise before this was going to change. I’m happy to say that this has changed. These days, yes, you’ve still got a few that speak at many of the conferences, but most conferences try to bring in fresh faces and fresh ideas.

When I started doing virtual conferences at Day Camp 4 Developers, it was because only about 1%-2% of PHP developers could get to a conference. Most companies wouldn’t spend the money to send a developer to a conference and most developers couldn’t afford it on their own.  Now, virtual conferences are a necessity of life. Hopefully one that will go away, but night now, there is no denying that virtual events are de rigueur for a while to come. Of curse nobody wanted it to be this way but the silver lining is there are a LOT more opportunities for PHP developers to learn.

When I first heard of the Dutch PHP Conference it was because I was blessed to be asked to speak at the very first one. Back then it was a small one-track conference with 200-300 people in attendance. Fast forward a few years to 2009 and I was honored to actually get to help run the conference. That year we have 3 tracks and a little more than 3x the number of attendees.

Now, for the second year in a row, I am hosting DPC again. This year, like last year, it will be a virtual conference. This year, like last year, the main conference day is free. (And now you know why I don’t run Day Camp 4 Developers events anymore. :) )

It has changed a lot since that very first one, but at it’s core, it’s still run by the same people for the same reason. See, I think the reason I like DPC so much is because I know the people behind the curtain. Joni and Tom have been friends of mine for more than 10 years now, and I see the effort that they – and the entire company – pour into DPC. I respect that they do this out of love.

So it’s an honor for me to be associated with DPC again. I’ll gladly stand in front of a camera for this this year, tell bad jokes between speakers and introduce those speakers to you. Yes, some of the speakers will be old friends of mine. Some of them are new friends of mine. All of them though are members of the herd – the PHP community – and that’s really all I need to know.

Join me and my old and new friends on June 18th for DPC21. If you want to seem some long-form sessions, there are still tickets available for the June 17th talks as well. (Those cost…still worth it)

If you have never been to a PHP conference before in your life, do yourself a favor and block off June 18th, 2021 and get yourself a ticket to DPC21.

As I say for Day Camp 4 Developers “Invest a day in your career” :)

Oh and make sure you join the slack channel and say hi. I’ll be the one telling the bad jokes. :)

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

DPC21 – YAOC

Dear Reader,

Welp, here I are staring at June 2021 on the calendar and know that one of my favorite PHP community events, The Dutch PHP Conference, is yet again going virtual. Yup, Yet Another Online Conference. (YAOC) Just another day of YAOC Shaving in a polo shirt and my pajama bottoms.

Don’t get me wrong, I understand and applaud their commitment to the safety and health of the attendees. But come on, there’s only so many times I can get excited about seeing some of these people present again via Zoom. I mean a few of “the regulars” will put you to sleep in an in-person presentation. Give me Zoom and a comfy chair to sit in and you had better end every presentation with an alarm clock going off.

You know my favorite part of on-line conferences though? The afterparty. I don’t have to watch how much I drink lest there be yet another “Cal’s Drunk” story going around. (Ask Joe Ferguson, last I heard he was collecting them all for a book. It will no doubt be masterfully edited by his much more talented better half.) Most of all though, I am the life of a virtual afterparty! (because it’s basically just me anyhow) :)

Still, given the circumstances, YAOC is better than NCAL. (No Conference At All)

It still gives me a day to set aside to hang out with the PHP community. A day I turn off everything else and sit and learn. A day I hang out in slack and make bad jokes. A day I get to catch up with old friends I’ve not seen in more than a year, and make new friends that I can look forward to meeting in person next year.

So yeah, YAOC. But the way I look at it it’s not YET Another Online Conference, it’s YEA! Another Online Conference. It doesn’t hurt that I’ve known the organizers of this event for more than 10m years and I know that virtual or IRL, they know how to throw a conference.

So if you aren’t doing anything on June 17th and 18th, come hang out with me. The slack channel is free an open to everyone. Yes, they don’t charge you a dime to watch me tell bad jokes.

This year, like last, the main conference day is free too. So get a ticket, block off the time in your calendar, brush up on YOUR bad joke or “Cal’s drunk again” story, and come hang with us at DPC21-YAOC.

I look forward to talking to you.

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

Lando DB Helper

Dear Reader,Lando logo

I use Lando a lot these days. I’ve got .lando.yaml files scattered all over my file structure. I love it because it takes the yak shaving out of development. One thing that bothers me though is the fact that every time I spin up a new lando instance and it has a database, it gets a new port number. I have to go find that port number so I can open my SQL editor to tinker. So over the past year I’ve been writing this little script. It’s finally to the point where I think it might be useful to others so I’m sharing it. Also, if I ever lose it, I’ve now got it backed up on my blog. :)

This is a snippet form my .bash_macros file. It creates the command db. Now all I need to do when I need to find the port for the database is type db and it shows me all the running db instances and their exported port numbers.

This was written in bash. I use it on Windows WSL running ubuntu but it should run on any standard Linux. Not sure about OSX.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Lando DB
# Author: Cal Evans
# Copyright 2021 All Rights Reserved
# License MIT
#
# Show what Lando (docker ) DB services are running and what port they are
# running on
#
function db() {
  RUNNING=$(docker ps --format "table {{.Names}}__{{.Ports}}\n" | grep 3306)
 
  echo
  echo "Lando databases running"
  echo "Instance Name : DB Port"
  echo "----------------:--------"
 
  for THISONE in $RUNNING
  do
    INSTANCE=$(echo $THISONE | awk '{print $1}' | awk -F '_' '{print $1}' )
    PORT=$(echo $THISONE | awk -F '__' '{print $2}' | awk -F ':' '{print $2}' | awk -F '->' '{print $1}')
 
    printf "%-15s : %s\n" $INSTANCE $PORT
  done
  echo "";
}

fClose()

This is one of those “this works for me so I’m sharing in case it works for you too” pieces of code. I didn’t setup a repo for it because I’m not interested in changes. If you do improve it, you blog about it and then we’ll all be the wiser.

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

Jeep Wrangler owners wave at each other

Dear Reader,

After 20 years of driving my little Miata, I finally traded it in and bought myself a Jeep Wrangler. (It’s much easier to tote scuba diving gear in a Jeep than in a Miata!)

Driving down A1A in Juno Beach the other day I noticed something. Every time I passed another Jeep Wrangler, the driver smiled and waved. (I passed quite a few, this was no small sampling)  It’s like I am now part of a secret club where no matter what we are doing, we take a moment to smile and wave at each other.  My wife, the lovely and talented Kathy, drives a Mazda 3. We pass those all the time and I’ve never seen any of their drivers smile and wave. Jeep owners however, identify as a group though and have determined that the group is a fun one.

As best I can tell, the rules of the group are, if you pass another Wrangler, you smile and wave. That’s it. I know I’m new to the group, but so far, what I’ve NOT seen is a Wrangler driver pass a Ranger Rover and scowl and flip them the bird. I’ve not seen Wrangler owners try to run a Hummer off the road. I know I’m still new to the group, but so far I’ve not noticed that it’s a rule that if two or more Wrangler owners are together chewing the fat, the rule is that we have to ridicule the car choices of non-wrangler drivers.

The rule seems to be, be nice to other Wrangler drivers, and there’s no need to not be nice to any other drivers.

Maybe in tech, we need to adopt these rules. Maybe we need to get together at conferences, user groups, or just online and talk about how awesome our tech stack is, without feeling it necessary to run down another tech stack. (i’m not just talking about people insulting PHP, I’ve seen plenty of PHP developers run down other tech stacks as well) Maybe, JUST MAYBE, the tech stack we chose works for us and for our problems, but it won’t work for others and solve their problems. Maybe, there’s more to the decision than whether it’s popular on Stack Overflow.

Maybe tech would be an overall better place if we adopted the Wrangler Rule. Be nice and wave at those who use our approved tech stack/framework, but don’t be mean to others that use something else.

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

Lando and WordPress Plugin Development

Dear Reader,Lando logo

So I’m working on my next book “Extending the WordPress REST API”. It’s the companion volume to “Using the WordPress REST API”. In this book, I actually have a working WordPress REST API controller and series of endpoints that I am showcasing. This means I’ve got development to do.

One of the hardest things I do in software development is WordPress plugin development. It takes so much to get things stood up and ready that it’s a pain just to start a project. My last few, I would spin up a site on an unused domain I own – don’t look at me funny…you’ve got them too – and then use VS Code to edit the files remotely. Not exactly the best solution but it’s a great excuse for not working when your not connected. (Scuba boat, airplane in times past, etc.)

Now though, that excuse has been taken away from me thanks to Lando. :)

Installing Lando

Installing Lando is not difficult. One of the great things about Lando it’s copious documentation. Anyone familiar with the basics of software development should be able to install Lando in no time regardless of their operating system. Thanks to Microsoft’s new WSL2 and some huge improvements in the file system, Lando now works better under WSL2 than it does on macOS. (I’ve done both)

I wrote up my thoughts on how to get Lando installed, up and running on WSL2 in this post, Making Lando work inside WSL2.

Developing a Plugin

Once you have Lando installed, the next thing we need is a plugin. You can use any plugin you are wanting to do development on. I’m using my wp_podcast_api plugin that I wrote for Voices of the ElePHPant, and that is the sample code for my book.

Once you are in your plugin’s directory, you have to create a .lando.yml file. Lando makes this part easy. Straight from the Lando Docs,

1
2
3
4
5
6
lando init \
--source remote \
--remote-url https://wordpress.org/latest.tar.gz \
--recipe wordpress \
--webroot wordpress \
--name my-first-wordpress-app

Of course you want something more clever than “my-first-wordpress-app” but the rest is exactly what you need. This will create you a basic .lando.yml file. This also downloads and uncompresses the latest version of WordPress. This is necessary for when we fire things up.

Now we start tinkering. You can find the finished product here, in case you are too impatient to read this.

The Basics

The basic .lando.yml that the init process created for us is just that, very basic.

1
2
3
4
name: my-first-wordpress-app
  recipe: wordpress
  config:
  webroot: wordpress

That’s it. It just defines our webroot. By the way, you CAN change that if you want but there’s very little value to be gained unless you’ve got something hard-coded to public.

Config

For our working environment, we want a little more than just the basics. We want ti decked out exactly the way we like to develop, otherwise, whats the point in using Lando to begin with? So I’m going to walk through each part of the finished .lando.yml file explaining why the lines exist and why I set them this way.

1
2
3
4
5
6
7
config:
  via: apache
  php: 7.4
  webroot: wordpress
  ssl: true
  xdebug: false
  database: mariadb

I am now and have always been an Apache fan. So I build with Apache. If you like nginx, that’s cool you can specify that. I’m developing using PHP 7.4 like every good PHP developer should. Also, I like MariaDB over MySQL. I don’t currently use xDebug on this project but I can easily turn it on and then lando rebuild to use it. Of course, everyone should use ssl. It’s not that important for development so it’s fine to leave that off if you like.

Services – Database

Services one gets a bit long so I will break it up into smaller chunks.

1
2
database:
  portforward: true

I want to be able to access my database from outside of the Lando container, so I tell it to port forward. Here’s the thing about Lando and port forwarding you can turn it on or off, but it’s best if you let Lando decide the port to forward. Let me quote the Lando manual for you.

portforward will allow you to access this service externally by assigning a port directly on your host’s localhost. Note that portforward can be set to either true or a specific port but we highly recommend you set it to true unless you have pretty good knowledge of how port assignment works or you have a very compelling reason for needing a locked down port.

portforward: true will prevent inevitable port collisions and provide greater reliability and stability across Lando apps. That said, one downside of portforward: true is that Docker will assign a different port every time you restart your application. You can read more about accessing services externally over here.

I mean seriously, I could expound on it, but why. They said it best.

Services – Appserver (Apache)

This is the big section so let’s break it up into even smaller chunks.

The first is the overrides section. This is where the magic happens for WordPress plugin developers happens. That volume mapping below where we map . to /app/wordpress/wp-content/plugins/wp_podcast_api, that is the secret sauce. See, the .lando.ymlgoes in the root of your plugin directory. This way everything is kept together.

You cd in to your plugin’s working directory (on my laptop I have a directory named Projectsand all of my projects, including all of my plugins, have their own dir there.) and then you lando start. Everything stays together, everything in a single git repo, all nice and tidy. That mapping makes this possible.

1
2
3
4
appserver:
  overrides:
    volumes:
      - '.:/app/wordpress/wp-content/plugins/wp_podcast_api'

Now when lando starts up, you get a directory in /app/wordpress/wp-content/plugins/wp_podcast_apithat is your plugin, just like you need it. Since it’s a mapping, you can still edit the files in the root of your project and your webserver sees those changes.

Literally, after lando startmy next command is code . and I have my editor up and running ready to start building some awesome.

If this were a simple plugin, that would be all I would need. However, this particular example depends on other plugins. I don’t want to have to re-install them every time I lando destroy -y && lando start so let’s use a combination of composer and wp-cli to put them in place and configure them. Of course we don’t do this manually, let let Lando deal with it. :)

Services – Appserver Build and Run

Lando’s .lando.yml has 4 sections under each service where you can define things that are to be executed inside the container.

  • build_as_root
  • build
  • run_as_root
  • run

The *_as root should be obvious from the names, in the case of this sample plugin, we don’t use them, just build and root. These execute every time you lando start from scratch, you lando rebuild, or you lando destroy -y and then lando start. If you just lando stop and then lando start again (or lando restart) these steps do not execute.

build
Build executes before the services have been started. If you need to download stuff, tinker w/config files, etc, build is your friend. (same for build_as_root)

1
2
build:
  - wp core download --force --skip-content

Now I know what you are thinking…WE JUST DOWNLOAD CORE! Yes, we did, for the init. However, if you want to start totally from scratch. (commit this to a repo, delete the dir, clone the rep anew and rebuild it with Lando) then you need this command.

run

run executes after the services have started. If you needs the services up and running to do a task, you want those tasks in run. In our case, we do several tasks here in run.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
run:
  - composer install
  - wp config create --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbhost=database --skip-check --force
  - wp core install --url=podcast.lndo.site --title=Podcast --admin_user=admin --admin_password=admin --admin_email=cal@example.com
  - cp assets/.htaccess wordpress
  - perl -p -i -e "s/\/\* That's all, stop editing! Happy publishing. \*\//\ndefine('JWT_AUTH_SECRET_KEY', 'bite-me');\n\/\* That's all, stop editing! Happy publishing. \*\//" wordpress/wp-config.php
  - wp theme install twentytwenty --activate
  - wp post delete 1
  - wp rewrite structure '/%postname%/' --hard
  - wp plugin install classic-editor --activate
  - wp plugin install jwt-auth --activate
  - wp plugin install wordpress-importer --activate
  - wp plugin install wordpress-seo --activate
  - wp plugin install powerpress --activate
  - wp plugin activate wp_podcast_api
  - wp import assets/voicesoftheelephpant.wordpress.2020-07-23.000.xml --authors=create
  - wp user update calevans --rich_editing=false
  - wp user update admin --rich_editing=false

Everything we do falls into two buckets.

  1. composer tasks (exactly 1 of these)
  2. wp-cli tasks

Lando was built for devs. It knows we love our tools. So when you told it you wanted to start with a WordPress recipe, it figured out that you need composer, wp-cli and a few other must-have tools ready to go. So by the time you get to run, they are there and waiting on you.

In out run section we make use of both composer and wp-cli these tools. This plugin requires a couple of other plugins to be installed. We use composer and wpackagist to get those installed properly. After they are installed, we use wp-cli to activate them as well the TwentyTwenty theme.

I’ve also got a few config options in there and yes, I install classic editor and turn off rich-text editing, I’m old skool.

Side note, while I use composer because it’s the tool I am comfortable with, I could have just as easily used wp-cli to download, install, and activate the plugins I a using because they all come from the main WordPress plugin repository. If you are using custom plugins from a private Packagist.com, composer is your best route. If you know how to use both then you can figure out the best tool for the job each time.

Services – mailhog

Finally, one of my favorite things about Lando, I tell it to setup mailhog. This is a real simple email testing service. When you spin up Lando with mailhog it gives you a URL to go to that shows you any email that was sent to anyone. The mails are not sent out over the net but just captured for you to examine.

1
2
3
4
5
mailhog:
  type: mailhog
  portforward: false
  hogfrom:
    - appserver

Since WordPress can send a lot of emails and we want to make sure they are correct, mailhog is a great way to monitor them.

Bring it all together

Ok, if you’ve followed along so far and you’ve tweaked your .lando.yml file, you can now spin it up.

1
$ lando start

That’s all it takes.

If you look at the final lando.yml file, you’ll see that I use the wp importer tool to import a set of posts. You can also use lando db-importto populate your database from a .sql file. If you have awesome friends like Kim Cottrell then you’ve probably got a good companion tool like lando db-download that exports and downloads your production database for you.  Or you can do like I did for this one and just use XML. It doesn’t suck that bad. :)

When you are done, you can stop it with a simple

$ lando stop

Don’t destroy it with lando destroy -y unless you aren’t going to be back for a while. stopping and restarting is a lot faster and preserves you database.

As you can see from my sample plugin’s repo, I keep all of this, .lando.yml, composer.json, and the plugin code, in the same repo. This way, no mater what machine I am on, if Lando is installed, I can git pull and then lando start to be up and running with a full WordPress development site faster than light-speed. (Sorry, couldn’t resit) :)

 

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