I have been using Sage 8 for a little while now to power some of my WordPress projects. I really liked the Gulp and Bower aspects and, while it took a bit of fiddling around to get a nice base theme for my projects, it was worth it in the long run.
Now that the first beta of Sage 9 has been released and I am pretty interested in getting to grips with the new features… especially learning about Webpack which is quite new to me. So I thought I’d write something of my experiences, and this first post is all about getting started.
Please note that I am going to include a load of basic setup stuff that most advanced users won’t care about, but perhaps someone relatively new to Sage or Composer or even command line (like me) will find some useful nuggets here.
Download Sage 9
I started out by looking at their Sage 9 beta blog post here which talks about loads of things that I don’t understand, so in true gung-ho fashion, I decided to quickly move on to the theme installation instructions. May as well “learn by doing”, right?
The first four words I read were: “Install Sage using Composer…”. The first hurdle: I have never used Composer. I couldn’t get it working with Sage 8.5, so I usually just skipped that and installed the necessary files the old fashioned way. This time around I thought I would do it right.
So the first thing I did was to install Composer. So I went to the Composer download site and started following the instructions.
At this point I hit problem number 2: My PHP was a couple of versions too old for Composer to work (it wanted 5.6 and I was running 5.4). This seemed odd to me because I was running MAMP which, when I looked in the preferences tab, claimed that it was running PHP v5.6.10.
It turns out that my Mac thought that I should use an older version of PHP which is installed at usr/bin/php, and ignore the settings on MAMP… I am sure it had some good reason for this that was beyond mere human understanding.
Ensure new version of PHP
So I found this post to be of use at first: Instructions on how to change preinstalled Mac OS X PHP to MAMP’s PHP Installation and then install Composer Package Management.
But quickly stumbled on my next hurdle: I don’t use the regular Terminal bash wotsit, so these instructions only partly worked for me… Like ‘which php’ – That one worked fine, and insisted on the wrong location /usr/bin/php
I actually prefer to use ZSH for my command line work, with the help of the Oh My Zsh framework.
Putting the final pieces in place
So after a bit more searching I found this: Change default Mac OS X PHP to MAMP’s PHP Installation on oh-my-zsh. Which explained what I needed to do in nice easy language I could understand.
So, at last, I had my newer PHP version and I was able to finish installing Composer.
Well, almost. I could see that Composer was now installed, but when I try to run:
composer create-project roots/sage [your-theme-name] dev-master
I was being told that Composer command could not be found.
I found a couple of possible solutions for this which all sounded a bit too long-winded and technical for me, so after a bit more searching I was able to find this solution, and simply replace composer with ./composer.phar like so:
./composer.phar create-project roots/sage [your-theme-name] dev-master
I think it was this post (Composer command not found) which pointed me in the right direction.
And now it’s working?
Well, yes, I have installed Composer and, in turn, Sage 9 theme successfully. However there were still a few more bits to do: I had to install Yarn which is a package manager that I have not used before. This look a bit like Gulp (in terms of getting Browsersync to work outputting files to dist, etc.). Anyway, this was actually pretty painless… As with all good web dev, there were a few preceding hoops to jump through, namely: I had to update Homebrew. On my command line:
brew –version (Checked the version)
brew update (Run a quick update)
brew install yarn (Install Yarn)
Ready to go!
Well after all that, I was pretty exhausted and decided to work on the rest of Sage 9 another day. A lot of web dev these days seems to involve setting up package managers! Maybe this blog post will help somebody else who’s having problems setting up Sage 9?
In part 2 of this series, I’ll actually start building something with Sage 9 and give some of my views on that.