WordCamp Johannesburg 2018 – Workshop prep

On Thursday the 25th of October 2018 I will be presenting a workshop titled “Turning your WordPress plugin into a SaaS”, where I will be sharing some insight into connecting a WordPress plugin to a Laravel App through HTTP requests.

As with most workshops, there is some preparation work required to attend. However because we are dealing with two different platforms, (Laravel and WordPress) setting it all up might take a bit longer than usual.

TL;DR – Requirements:

This article is aimed at folks who a) have never set up local development environments or b) have only ever used applications like WampServer or Mamp for their local development. If you already use something like Vagrant or Docker environment, you probably don’t need this article 😉 It would however be good to skim through it to make sure you have a set up that matches my own.

1. WordPress environment.

To participate in the workshop, you will need a local WordPress environment. Make sure you have the latest version of WordPress installed (4.9.9 at the time of this article).

If you use WampServer or Mamp, you should be fine, as long as the WordPress install can be accessed via a local IP address (we’ll get to that in a bit).

My recommendation would be to try something like Chassis.io, or my own BossBox. These are pre-configured WordPress ready Vagrant boxes that replicate a Linux server and any installed software you might need. If you already use VVV, this is also a good option.

To install any of these options you will need to install VirtualBox and Vagrant first. Each project has instructions on how to set up and run your WordPress install. Obviously I favour BossBox, because I built it and I know it works well out of the (ahem) box.

What I like about a Vagrant option is that you can configure each instance with it’s own IP address, which makes it easier to develop and test API end points on two different instances at the same time, which is what we’ll be doing in the workshop.

You will then need to download and install the base plugin we will be using, which you can download from this link.

For the purposes of the workshop, my WordPress environment will be using the default IP address which ships with BossBox, which is 192.168.33.10.

2. Laravel Environment.

Firstly you’ll need to follow the installation instructions to create a new Laravel project.

Then you’ll need to choose which local environment you use. There are a few options to for setting up a local Laravel environment, the two most popular being Laravel Valet and Homestead.

Laravel Valet as a Mac only option, that requires very little in the way of set up. The only downside is if you don’t own a Mac, you can’t use it. I develop on a Linux OS, so I can’t speak for if it will be sufficient for the workshop, but I don’t see why it wouldn’t. As with the Wamp or Mamp options I also don’t know if you can configure the Valet set up to a local IP address.

The option which I prefer is Homestead. Again, it is also a pre-built Vagrant box, so if you go with one of the Vagrant options for WordPress you already have the required software installed. If you do go this route, I suggest using the Per Project installation method, which is the one I’ll be using for this workshop.

For the purposes of the workshop, my Laravel environment will be using the default IP address which ships with Homestead, which is 192.168.10.10.

A note on Vagrant options: because these pre-built virtual Linux web servers, they can be quite large when you first download them. BossBox is around 750mb (the last time I checked) and the Homestead box is almost double that. So make sure you have a good internet speed and enough data to complete the downloads. If you only use mobile data, I recommend visiting an internet cafe or WiFi enabled coffee shop or co-working space. It’s also the reason I suggest you do this before you come to the workshop, as downloading everything during the workshop is going to take too long on conference WiFi. The upside is that once they are installed, you use the same installed base box for every other instance you set up.

3. Database Access

You will need some way to access the database for both set ups.

If you use the BossBox route for your WordPress setup, you can access the database via PHPMyAdmin, which comes pre-installed on the box. You will find details on how to do this in the project readme file. If you go with the Homestead route for Laravel, you can use an application like MySQL WorkBench. For the Laravel app the defaults are:

  • Hostname – 192.168.10.10
  • Port – 3306
  • Username – homestead
  • Password – secret

For which ever set up you choose, make sure you can connect to and view the database for both.

3. API Testing – Postman.

Postman is an application for testing software API’s. We’ll be using it to test the API end points we create during the workshop. To make sure your WordPress and Laravel environments are accessible to each other, test them via Postman.

In order to test them, you need to install Postman and create two new requests, one for WordPress and one for Laravel. Set the URL for each request to the IP address for both WordPress and Laravel. You should see some html data returned, which means Postman can send a request to either one.

4. Code Editor/IDE.

Obviously we’ll be writing code, so we’ll need a code editor. If you are already writing PHP code you probably have an editor you prefer, and that’s great. If you don’t I can recommend Visual Code Studio (free) or PHPStorm (paid). PHPStorm comes with a free 30 day trial, so if you’ve never tried it, now is a great time. I’ll be using PHPStorm in the workshop.


Posted

in

by

Tags:

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.