Installing Craft CMS, Statamic and Perch Runway on Laravel Valet
A long time ago one of my favorite things to do on the web was to explore content management systems. It still is.
Around 1999, I used to visit my friend and play around on PC computers. We’d install scripts like Francisco Burzi’s phpnuke just for the fun of it. View source and installing programs was how I learned to build websites. The web in those day was an exciting time. Today is no different. Twenty years later, I’m still excited about the web. Tonight let’s setup a new development environment and try out a few modern content management systems.
Today, alternatives to Drupal and WordPress have never looked better. To escape the orbit of WordPress and its tangled web of backwards compatible code. To keep structured content and avoid Drupal complexity. It is possible. Of course there is beauty and utility in the big planets. Each has its place and purpose. Yet life and real innovation is happening on smaller worlds. These alternative tools help writers create rich media experiences and inform the UI designs in more popular tools. Drupal Gutenberg and WordPress Gutenberg give editors new tools to share stories. Yet, so far Gutenberg has fallen short on accessibility and structured content. It is worth while to demo the competition and check out the alternatives. Plus for me it’s fun to tinker and play.
Roy describes the project:
The purpose of this plugin is to save Gutenberg (New WordPress Editor) data as an array in the database which is accessible via the REST API…
While the new UI for the WordPress Editor is amazing, the data as it is stored lends a lot to be desired with HTML comments as a basis for data.
the new systems show the viable ways to separate content from presentation and help developers. So much to explore. If only we could escape the pull of the big giants.
Content Management Systems and Laravel Valet Links
- Craft CMS. A flexible, user-friendly CMS for creating custom digital experiences on the web and beyond.
- Statamic. Make better, easier to manage websites. Enjoy radical efficiency.
- Perch Runway is a breath of fresh air, it feels light, nimble and very powerful. A powerful CMS for developing content-centric websites
- Laravel Valet — Laravel — The PHP Framework For Web Artisans
Although this isn’t rocket science, some tools will help.
- HomeBrew. The missing package manager for macOS (or Linux) — The missing package manager for macOS (or Linux)
- iTerm my favorite terminal editor. Optional but recommended.
- Composer Optional but recommended. Composer is like npm the package manager for JavasScript, but PHP.
Back yet? OK. Super. Let‘s takeoff.
Pretty easy to install PHP. I only needed to run this command:
brew install php
brew services start php
That was easy. To test, run command
php -v Hmm. PHP 7.1.9. What happened? I thought brew installed 7.3 the latest version. Oh yea, I remember. macOS Mojave includes PHP 7.19. I could use that, but since this is an experiment I figure what the hell. Lets try the latest version of PHP circa February 2019. What could go wrong?
To point to PHP 7.3 I added
PATH=/usr/local/Cellar/php/7.3.2/bin:$PATH to my bash
Boot up nano, my terminal text editor of choice, open the file
nano ~/.profile and paste in the path and save. To activate, restart iTerm or reload your bash file by entering
source ~/.profile from the command line and hit return.
Now when I ran
php -v the results were
Moving in the right direction. Next step was to install MySQL.
Once more, we turn to brew to install MySQL. Here’s those command.
brew install mysql
And wait while brew does its magic.
brew services start mysql
And after a few nanoseconds, I saw this:
We've installed your MySQL database without a root password. To secure it run:
MySQL is configured to only allow connections from localhost by default
To connect run:
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
/usr/local/Cellar/mysql/8.0.15: 267 files, 234.6MB
Please do change your the root user’s password.
MySQL version 8 almost caused a big crash and burn. Apparently, it has a new authentication plugin for database connections that isn’t widely supported yet. Stack Overflow to the rescue. Although I found many posts Alexander Diachenko explained what was going on and offered a solution.
The error happened because MySQL 8.0.4 changed its default authentication mechanism from
caching_sha2_password. One of the ways to fix the issue is to run mysqld with additional option:
In short, for now MySQL 8 isn’t really usable out of the box with most existing client implementations.
Bit of a drag but not a deal breaker. I needed to up find my.cnf file. How to do that? With a little grep magic on the command line. Thanks to a Carpentries Unix Shell workshop I could use a little grep magic. The Carpentries teach foundational coding and data science skills to researchers worldwide. A fantastic group offering free lessons on python, Git, R programming to increase digital literacy among researchers.
mysql --help | grep cnf
which resulted in:
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
/usr/local/etc/my.cnf is the one we’re looking for since it had this text.
Default Homebrew MySQL server config
So I opened it with nano.
and pasted the following line to load the older plugin.
and restarted mysql
brew services restart mysql
Last fix was to alter a couple of users I already had created in MySQL so they would use the older authentication protocol.
ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
OK. That was kind of scary, but made it. You may decide to not go with bleeding edge versions of PHP and MySQL and that’s ok but I learned some new tricks. Onward.
Install Laravel Valet
For almost five years I’ve been using MAMP Pro to run my local server. I’m comfortable with it, but for the sake of exploration, and to make things more difficult I decided to install laravel valet. Once I got it running I see why its so popular. One benefit is I can run multiple hosts concurrently.
Of course Laravel Valet is optional and Craft, Statamic and Perch Runway can run with MAMP. Skip this section if you don’t want to venture into Laravel land, but since Statamic recommends running it, and you’ve made it this far already I think you’re an adventurous developer type so why not?
Back to the terminal and run the following command
composer global require laravel/valet . After it finishes downloading run
valet install command. This will configure and install Valet and DnsMasq, and register Valet’s daemon to launch when your system starts.
There is no need to run valet start or valet install ever again once the initial Valet installation is complete. Although knowing some of these commands will help.
valet link- used to serve a single site in a directory and not the entire directory. I prefer park
valet park- any project you create in your parked directory will be served with the http://folder-name.test convention.
I want to run more than one host on my computer so I’ll need to use
Create a new directory on your Mac by running
mkdir ~/Sites or if you already have it just
cd ~/Sites and run
valet park. This command will register your current working directory as a path that Valet should search for sites.
That’s all there is to it.
Now, any Laravel project I create within my “parked” directory will automatically be served using the http://folder-name.test convention. Cool!
By default, Valet serves sites over plain HTTP. However, if you would like to serve a site over encrypted TLS using HTTP/2, use the
For example, if your site is being served by Valet on the
craftcms-site.test domain, you should run the following command to secure it:
valet secure craftcms-site which creates configuration files.
To “unsecure” a site and revert back to serving its traffic over plain HTTP, use the
unsecure command like so.
valet unsecure craftcms-site
valet unsecure statamic.test
Installing Craft 3
composer create-project craftcms/craft ~/Sites/craftcms-site
Installing craftcms/craft (1.0.39)
Bunch of stuff downloads, while I went to sleep.
After waking up, feeding Ms. Fuzzy B Kitty and making myself a cup of fresh coffee I woke up the computer from its slumber, opened iTerm and saw:
______ .______ ___ _______ .___________.
/ || _ \ / \ | ____|| |
| ,----'| |_) | / ^ \ | |__ `---| |----`
| | | / / /_\ \ | __| | |
| `----.| |\ \----./ _____ \ | | | |
\______|| _| `._____/__/ \__\ |__| |__|
A N E W I N S T A L L
______ .___ ___. _______.
/ || \/ | / |
| ,----'| \ / | | (----`
| | | |\/| | \ \
| `----.| | | | .----) |
\______||__| |__| |_______/
Generating a security key ... done (**************************)
Welcome to Craft CMS! Run the following command if you want to setup Craft from your terminal:
Looking good. Now run the command
$ Which database driver are you using? [mysql,pgsql,?]:
and had to make a choice: use MySQL or PostgresSQL.
I haven’t used Postgres before so I’ll save that for another day. At the moment, I have enough to learn with Craft, Twig, Laravel Valet (might as well see what that’s about and not use MAMP.) and keeping some time left over for my mental and physical health. Plus after that trouble with the
caching_sha2_password MySQL 8.0 I wasn’t going to play around with fire twice.
So, MySQL it is.
I created a database, created a user with the privileges Check on Craft site for user permissions to set.
I ran the setup wizard, created a user and logged into my first Craft CMS site over with SSL using Laravel Valet at https://craftcms-site.test
OK then! Next up is Statamic. With no database it should be easier right?
Statamic is one of the simplest web applications to get up and running, but there are many different ways to run PHP…docs.statamic.com
composer global require statamic/cli
And got this result.
$ Using version ^1.0 for statamic/cli
$ ./composer.json has been updated
$ Loading composer repositories with package information
$ Updating dependencies (including require-dev)
$ Your requirements could not be resolved to an installable set of packages.
$ friendsofphp/php-cs-fixer v2.4.0 requires php ^5.6 || >=7.0 <7.2 -> your PHP version (7.3.2) does not satisfy that requirement.
$ Installation failed, reverting ./composer.json to its original content.
Oh well. Looks like I’ll need to wait to use composer to install Statamic until php-cs-fixer supports PHP 7.3. (Note php-cs-fixer v.2.4.1 does support PHP 7.3, but the brew repository hasn’t updated it at the time of this writing.
Guess this is what happens when living on the edge. I’m still happy. I’ve got Laravel Valet installed and can run Craft CMS over https. I’ll explore it first, and then try out Statamic in the near future.
Wait. Wait. Hold your horses. I got an idea.
Instead of using composer how about if I just download the zip file and follow the instructions on the Statamic site.
- Download the latest version of Statamic. Like Craft and Perch it is free for local development.
- Unzip files into your root folder
- Run the Trailhead Installer. Statamic has a little tool that will check your environment for all the necessary requirements, file permissions, locales, and help you get your first User created.
- head to
~/Sites/statamic-site/installer.phpfollow the instructions and after that’s done delete
valet secure statamic-site and login to the Control Panel at https://yoursite.test/cp and voilà now we have Statamic running over SSL.
Now both Craft and Statamic are installed.
What’s next? How about installing my favorite CMS Perch Runway!
Installing Perch Runway
I downloaded a free trial version of Perch Runway to run locally and copied it to my ~/Sites folder. Remember I have Laravel Valet parked looking for any sites with a .test domain so the server is ready to go.
I created a MySQL database, created a user and opened my browser to http://perchrunway.test/perch/setup. 404 error. No joy.
Out of the box, Laravel Valet supports for Craft, WordPress, Statamic and many others, including Drupal and WordPress, but it does require a custom driver for Perch Runway.
Fortunately, the Perch community is generous (like so many communities on the web) and Ryan Gittings, a percher from the UK posted a custom driver he wrote. In the perch community, developers are called perchers and we like to perchify a site. I owe him a beer, coffee or some kind of tip. Follow him on twitter. Or join the Perchology slack community.
Ryan’s instructions to install was straightforward. Copy his custom drive to Valet’s drivers folder here
Note: I compared Ryan’s custom driver to the SampleValetDriver.php provided by Laravel and decided to put back the isStaticFile function in case I need to run plain html static files. I forked his repo to my GitHub account.
In the Drivers folder I now have two files it looks something like this:
I ran the Perch Runway setup script http://perchrunway.test/perch/setup, created a new user, logged in and was in. To add SSL, don’t forget to run
valet secure perchrunway in the site’s root folder.
To finish delete the setup folder. Perch will show a message on your diagnostics, and that’s about it.
Here is what it looks like from the command line for all three sites
» ls -la
Now that I’ve got Craft, Statamic and Perch Runway served locally on Laravel my first thought would be do a compare and contrast and share what I learn about each cms. Including WordPress and SquareSpace I’ll have a roundup of best tools to take your site to the future and beyond.
Thank you for reading. If this setup doesn’t work on your mac or you have any comments reach me on Twitter.