Things run on things run on things

Part 2: Setting up a local environment

Statamic is built upon Laravel. Laravel is a framework of utilities built upon PHP. The new Statamic (Version 3) is now a Laravel app.

You need to install a few things first in order to get Statamic 3 running locally.

It’s not immediately clear what those things are as one thing needs another thing to run etc etc. There are a lot of things to install. For someone who starts sweating at the word "Terminal" this did not bode well.

It's immediately clear that Statamic is not Wordpress or any other click and install web application. It requires technical knowledge to get it running.

Firstly you need to run a local server. I’ve been using MAMP Pro for a long time. It’s a clunky beast of an app and can be a pain to manage when things go wrong. You can continue to use this though.

Statamic recommends using Laravel Valet to host sites locally. Valet is a self-contained hosting package that is installed from the Terminal.

Using the Terminal is something I’ve avoided for a long time. But I thought I'd give everything a go and note it down here.

Sleeves rolled up: Let’s go!

Like many things in life there are a few steps you need to go through in order to even start what it is you set out to achieve. Open Terminal. Go on, you know you want to!

Step one. Install Homebrew

Homebrew is a package installer for MacOS. Yeah, I don’t know what that is either.

First run the following code:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Once that's installed you can install PHP with brew install php

Install Composer

The next instructions are Install Composer. This is a Dependency Manager. What the hell is that you ask? Well I think it looks after libraries within each project - or website in my case.

Statamic uses Composer for all kinds of things, including installation and updates.

I would recommend installing Composer globally. This means that you don’t have to install it every time you add a new website project.

Update: I had this message from Erin, one of the big boys, on the Discord channel "Only change I’d suggest is to install composer via brew". I haven't tried this myself but you can with brew install composer.

It’s a bit of a faff for a newbie, so I hope these notes help get you started.

First you can download Composer using the code below or download it from the Composer website.

curl -sS https://getcomposer.org/installer | php

Then install Composer globally by installing it somewhere it can be accessed by the system like the path below.

php composer.phar /usr/local/bin/composer

You can then create shortcuts in Terminal so that you just use Composer rather than php composer.phar. You do it using the instructions below.

There seem to be a gadzillion ways to do this but the latter version worked for me. I am running zshrc rather than bash because I am cool like that (actually, that's what comes as standard with MacOS 10.15).

Open the configuration file in Text Editor.

open -e ~/.zshrc and add the line alias composer="php /usr/local/bin/composer", or export PATH="$PATH:$HOME/.composer/vendor/bin" I have no idea what the difference is between the two. The second one works for me.

Restart Terminal. This now allows you to install Composer in the project folder.

Change directory (cd path/to/folder) to your web project folder and run the following code: composer install. It's no surprise that Composer will now install.

Install Valet

You are now ready to install Valet.

You don’t have to run Valet. Any LAMP-based server is fine. e.g. MAMP Pro is fine if that’s what you are used to.

Run composer global require Laravel/valet.

Now run Valet install

You can test if Valet is running by pinging a domain with the suffix .test

ping folder.test should return 127.0.0.1

Huzzah. You’ve got Valet running locally. Pour yourself a stiff Ribena.

If you are going to run multiple sites then you probably want to serve your sites using park. Park acts like magic. Once you’ve assigned a folder to Valet then any immediate subfolders will be treated as stand alone sites:

Sites
	- website_1
	- website_2
	- website_3

It is easy to set up. Create a directory with mkdir ~/Sites. Change Directory into that folder with cd ~/Sites. Now run valet park.

Any folder created is reachable in the browser with http://folder_name.test

That should get you started. There are lots of extra options and settings over at the Valet website.

My thoughts

To a designer all this technical stuff seems pretty painful but, rest assured, you only need to do this once on your local machine.

Valet starts automatically. It also seems to play nicely with MAMP, at least on my installation. MAMP will complain about other services running on the same port but you can ignore that. All my old MAMP-based sites work fine and I haven't noticed any issues at all.

It’s really daunting to do this if you are coming from a lifetime of ftp and plain old HTML and CSS files.

It feels very much like you are installing a whole new multi-layered world of applications to do pretty much the same thing. I questioned the need for all this dependency.

On the plus side, you are learning lots of commands and practices that will serve you well in the future and make you more confident when working with live web servers.

I had a bit of trouble install composer globally but the rest of the process was really simple.

I have learned more about the Command Line in the last three weeks than I have in the last 15 years! I like it. I feel powerful. Like a Lord of the Future.

Part 3: Installing Statamic 3