Category Archives: Uncategorized

Deploying Laravel 5 & 6 to CloudWays using Envoyer

CloudWays has a super basic introduction to using Envoyer with CloudWays – but disapointingly it doesn’t actually cover any of the things specific to CloudWays. It’s just a generic introduction to a super basic deployment over SSH.

I’ve spent the best part of today getting things running, and wanted to share what I’ve done – to hopefully to help someone else, and also to request feedback from others.

I like automation, I don’t want to have to be doing things manually. That’s the purpose of Envoyer too. When I trigger a deploy in Envoyer, I expect my production site to be fully updated – composer, compiled assets, caches cleared, database migrated.

A little disclaimer

This process has been my attempt to set things up according to best practice. For me, best practice means automating as much as possible to eliminate human error (i.e. me forgetting to run something).

I’m setting this up in August 2019 – if anything doesn’t work well I’ll come back and update this blog (hopefully!). Otherwise please treat this as a suggestion, rather than something tried and tested. Likewise – I’d love your feedback or experiences in the comments below.

Deployment Hook Positions

Here are the Deployment Hooks I have setup, the content for each is in the table after. This one just shows where I’ve positioned each.

Clone New ReleaseBackup
Install Composer DependenciesInstall NPM Dependencies, Build Assets
Activate New ReleaseRebuild Cache, Migrate DatabaseReset App Permissions on CloudWays, Restart FPM on CloudWays
Purge Old Releases

Deployment Hook Content

NameRun AsScript
Backupmaster# Backup the current site, before doing anything.
# Uses package: backpack/backupmanager
cd {{ project }}/current
php artisan backup:run
Install NPM Dependenciesmastercd {{release}}
npm install
Build Assetsmastercd {{release}}
npm run production
Rebuild Cachemastercd {{release}}
php artisan clear-compiled
php artisan cache:clear
php artisan view:clear
php artisan config:cache
Migrate Databasemastercd {{release}}
# Migrate the database without asking us
# if we’re sure.
php artisan migrate -n –force
Reset App Permissions in CloudWaysmasterCURL command (see blow). It was very long and messy to paste in this table.
Restart FPM on CloudWays master# Envoyer can’t restart FPM with the CloudWays SSH user
# but we can easily do it using the API.
CURL command (see blow). It was very long and messy to paste in this table.

Don’t forget to tick the “On Servers” box for each one, too.

Which user to deploy as?

One of the issues I’m trying to overcome is the occasional permissions issue I get in cache (especially template) files on CloudWays. Because I’m compiling my assets as the “master” user, but Apache is running them as the “application” user.

I started of trying to run everything as the application user. But that user cannot run npm properly (permissions issues creating ~/.npm).

I also tried to get the application user to build the assets and do the cache clearing – but again I was getting permissions issues and errors. I presume that’s something to do with the locked down users CloudWays configures.

So in the end – I’m running everything as the master user.

Using the CloudWays API

The CloudWays API is very simple to use, I used the Playground (don’t forget to Authourize with the button in the very top right) to generate the CURL call needed. Heads up: the Bearer header is not your API token, but is created when you authourise on the API Playground.

Grab the Server ID and Application ID by loading the CloudWays platform page and getting the numbers from the ID.

CloudWays API Command to reset file permissions

Since I’m trying to avoid file permissions issues (caused by compiling things or clearing caches as the master user, but serving them as the application user) I opted to run CloudWays’s File Permission Re-setter tool after every deploy.

curl -X POST –header ‘Content-Type: application/x-www-form-urlencoded’ –header ‘Accept: application/json’ –header ‘Authorization: Bearer YOUR_API_TOKEN’ -d ‘server_id=YOUR_BEARER_ID&app_id=YOUR_APP_ID’ ‘’

CloudWays API Command to restart FPM

Envoyer can’t restart FPM over SSH because CloudWays doens’t let us sudo. But we can do it with the API instead. Make sure you’ve got the correct PHP FPM version. Use the /service/get method to check what it should be.

curl -X POST –header ‘Content-Type: application/x-www-form-urlencoded’ –header ‘Accept: application/json’ –header ‘Authorization: Bearer YOUR_BEARER_TOKEN’ -d ‘server_id=YOUR_SERVER_ID&service=php7.3-fpm&state=restart’ ‘’

Change Log


  • Changed page title to include Laravel 6 – which I’m now using.
  • Moved “Build Assets” from “Before Activate New Release” to ” Before Install Composer Dependencies” to resolve “Mix Manifest not found” error.
  • Moved “Install NPM Dependencies ” from “After Install Composer Dependencies” to “Before Install Composer Dependencies” because it has to come before “Build Assets”

Comments, Suggestions, Feedback

As mentioned above, this is a voyage of discovery for me. Hopefully it’ll run smoothly going forward. I’ll definitely be adding to it (I intend to setup the Laravel Job Queue at some point).

Please share below any experience or suggestions you have. I struggled to find any detailed articles addressing this so hope to create one.


Object to the Hasmoneon Development on Copthall Fields

The decision is now with the Mayor of London

If you’d like to object to the planning application to build on the Copthall Fields (please do!) this is what you need to do, since Barnet (narrowly) approved it – it’s now with the mayor.

Click here to open your email client with the below details pre-filled.

Send your email:

To: [email protected]

CC: Andrew Dismore <[email protected]>

Subject: Objection to planning application Ref: 16/6662/FUL Hasmonean High School 2-4 Page Street London NW7 2EU

Body: In the body explain why you’re against.

Email Body Tips

Format your email body like this:

  1. A nice formal greeting. “To whom it may concern” or “Dear All”
  2. A sentence or two about who you are and your connection to the field. (e.g. a local resident, someone who explores London’s green spaces etc).
  3. List your reasons for objecting (only some things can be considered – pick them from the document below).
  4. Thank them for their time, and perhaps say you’re looking forward to their decision.
  5. Sign off with your full name and address (required, without your name and address the objection can’t be used).

You can only object on certain grounds, use this easy guide to see what you can object based on. You don’t need to write much, just mention why you’re objecting.

Do this soon! The mayor only has another week or so to respond.


Share this page with anyone you know who would value keeping places like this available to the public. Talk to your friends and neighbours.

Contact the local group of residents to see how you can help further:



Draft: Coder requests for Graphic Designers / How to design for code

WORK IN PROGRESS – this is a work in progress, if you have anything to add let me know here:  contact me!

Design is important, really important. Making things look right has an incredible impact on how visitors use our creations.

But not all design is essential, and not all styles are fixed.

Over many years of coding designs from mockups I’ve come across many habits graphic designers have which are very complicated to code.

So in my quest to ease Designer/Develoepr relations I’m compiling here a list of tips for designers to help them create designs which are easy (or not very messy) to code.

Naturally, if a design is wanted it can be coded. The Internet is magical like that – but if it doesn’t really matter if the logo is 2% larger on tablets than mobiles, lets keep them the same and keep the code sane.

Do use Rows

Everything on the web is either a rectangle or sits inside a rectangle.

You cannot see the rectangles which are responsible for layouts, but they’re still there. Making them overlap is possible, but not easy to do right.

Keeping things aligned in these invisible rows and columns makes coding life much easier.

Don’t make small changes

Every tiny visual change requires code to make the change and define when or where to apply the change. Having a button be 3px taller on the newsletter signup form than on the contact form requires about an extra 6 lines of code.

Don’t mix percentage and fixed widths

Having the form-labels be a fixed 150px wide and the form element take up the rest of the page is not fun to make happen in code. Either use percentage widths, or use fixed widths (which can be defined differently at different overall widths, but see “Don’t make small changes” above.


WordPress Shortcodes for Website Editors

Overview of Shortcodes

WordPress Shortcodes are snippets of code which WordPress turns into more advanced things. For example the gallery shortcode is very simple in the editor, but turns into a complicated bunch of code for displaying many images.

A basic shortcode is a word wrapped in square brackets, like this:


Simple Shortcode

A shortcode to display the most recent posts might look like this:


you can put that anywhere you like in your post body and when you view it on the front-end of the website it’ll display a list of recent posts.

Closing Shortcodes

Some shortcodes can be wrapped around some text, for example a shortcode might make a paragraph stand out and flash. In this case you put the usual shortcode form above before the content, and a repeat of it but with a forward slash added after the first square bracked after the content.

[stand_out_and_flash]This is the content[/stand_out_and_flash]

The shortcode will then generate some code to go before and after the content – in this case to make it stand out and flash.

Shortcode Settings

A shortcode can also have settings – this lets you use the same shortcode in different places but with different results. Taking the example of the recent-posts shortcode above we might want to choose how many of the most recent posts to show. We do this by adding a space after the shortcode name, followed by the setting name, and equals and then the value – followed by the closing square bracket.

You can add as many settings as you like (as long as the shortcode supports them) by repeating the format.

If the value of the setting contains a space (or some other special characters) you need to put it in quotes (you can put all values in quotes if you prefer too).

You don’t repeat the settings in the closing shortcode (E.g. the [[/stand_out_and_flash]] – they are always just a forward slash followed by the shortcode name.

Here are some examples:

[recent-posts count=10 order="oldest first"]
[recent-posts count=5]
[stand_out_and_flash flash_speed=fast] This will flash really fast[/stand_out_and_flash]

Have any questions or tips about Shortcodes? Ask in the comments below.


Don’t be Proud of Who You Are

Nobody’s Perfect

Everyone has things about themselves that they’d like to change, that’s not a bad thing. That’s what makes good people good.

We hear a lot that we should be proud of who we are, that nobody’s perfect and that’s OK. In fact it’s often said that it’s a good thing, we should surround ourselves with people who accept us for who we are.

Load of rubbish, I say.

I say surround yourselves with people who inspire you to be a better person, good friends love you for who you are – great friends love you for what you do and how you do it.

Everyone has dreams

When I was younger, I had lots of dreams. Some were realistic – I wanted to be a chef. Some I knew would only ever be dreams – how could I be a rock star if I couldn’t play music and sing/think/tap my foot at the same time?

Over time, these dreams changed. I realised that what I really wanted, was to make the world a better place. None of this “world peace” or “free Tibet” style better, I’ve never felt qualified for those.

The handy thing about a dream like “make the world a better place” is that is got quite a lot of scope, but it’s quite simple to do. At the end of the day I realised that the best way to do my bit for world peace is to become a better person.

This has the added advantage of being rather handy in my day to day life too.

Change Yourself

So I set about becoming the Sami I wanted to be. This started in Israel, where I knew nobody and could be whoever I wanted – I could ‘try out’ different behaviours, senses of humour, and see which I felt most comfortable in. That’s not to say I wasn’t comfortable before I went, but I was certainly more happy being the post-Israel me.

That was the most important thing I’ve ever learned – that it’s OK to change. You’ll make and lose some friends along the way, but that’s going to happen anyway (because change is OK, remember?).

Ever since then, I’ve thought about who I want to be, and how I want to get there. I’ve become comfortable as myself – step one. Over the past couple of years I’ve become more organised – step two. Next up, to become work-organised (a mysterious concept known as ‘having free time’) and to become healthily-organised. That last one’s a bit of a drag, I’ve never enjoyed exercise when it’s not a by-product of the quickest way to get to the train station.

But it’ll make me a better person, which will (in it’s own tiny way) make the world a better place.

So don’t be proud of who you are, be proud of who you have made yourself – and of who you want to be.


Installing PEAR, PHPUnit and Selenium on Windows

I wrote this for use at work, hence some of the wording. I may re-edit it one day, but it should do the trick. Feel free to leave any comments or questions below.

Installing PHPUnit on Windows is done with PEAR.

Installing PEAR

  1. Create the folder c:\program files\PEAR (This is your PEAR path)
  2. Download go-pear.phar from here: (the one which comes with PHP is usually broken) and save it in your PEAR path.
  3. Open a command prompt and navigate to your new PEAR folder, type php go-pear.phar
  4. Hit Enter to agree to a System install then Enter again to confirm all the settings are good (after checking them, of course).
  5. PEAR is now installed. When we use PEAR to install things, it creates a .bat files in our PEAR directory which can is used to run them. For example by the end of this page PHPUnit.bat will be installed and we can call it from the command line as ‘phpunit’ since windows is clever like that.

To be able to run these commands from outside of the PEAR directory we must add the PEAR directory to our PATH Environment Variable.

  1. Press Windows Key and Pause/Break to load the System screen.
  2. On the left click on Advanced System Settings.
  3. Click on the Advanced tab then “Environment Variables..” button at the bottom.
  4. In the bottom list, “System Variables” find and select the PATH variable and click Edit.
  5. Add a semi colon to the end of the list, and enter the path to your PEAR directory.
  6. Click OK and then OK again.

You will need to open a new CMD window if you already have one open so that you get one with the new environment variables available.

  1. Run “pear upgrade” to test and get the latest version in one handy step.

Installing PHPUnit

Navigate to your PEAR folder and run the following commands

  1. pear config-set auto_discover 1
  2. pear install --alldeps

PEAR creates a file called PHPUnit.bat, which we can run from anywhere because we put our PEAR directory into our PATH variable in the first step. It’s also created a bunch of other files which PHPUnit.bat uses.

You may wish to add C:\Program Files\PEAR\pear\PHPUnit to your php.ini include_path.

Installing Selenium for Integration Testing

Our Integration Tests use Selenium and involve launching a browser and running through things, they take siginificantly longer to run than Unit Tests and you’ll probably not run them every day. They’re useful when you’re changing the back end but not the UI, and will  need updating if you’re making changes to the UI. They also pick up JavaScript errors.

Selenium is a server to which PHPUnit will connect and issue commands, the server then launches a browser and tells it what to do.

  1. You need Java installed, take the Offline version from here:
  2. Download Selenium Server here: Create a folder and save this in c:\program files\selenium\
  3. Right click on your desktop, go to New > Shortcut. For Location simply type “Java”, hit Next and type Selenium Server as the name.
  4. Right click your new shortcut and click Properties, at the end of the “Target” field add -jar “C:\Program Files (x86)\Selenium\selenium-server-standalone-2.23.1.jar”
  5. Running this shortcut should give you a console screen with happy output.
  6. To install the PHPUnit Selenium extensions (to be able to run the Integration Tests) download this file (or check for a later version of PHPUnit_Selenium from here) and merge the PHPUnit_Selenium-1.2.7\PHPUnit\Extentions folder with it’s sister in your PEAR Directory under pear\PHPUnit

Note that we are using Selenium 2, so you must use the Selenium2 classes.

Running the tests

Running the tests should take a matter of seconds and are run from the command line. From within the Squadify code base cd into the tests folder, type “phpunit” and hit enter, you should see something like:

PHPUnit 3.5.15 by Sebastian Bergmann.
.... Errors Come out here ...
Time: 0 seconds, Memory: 5.25Mb

PHPUnit looks for a file called phpunit.xml from which it learns how you with the tests to run. There are command line options for running only sub sets of the tests specified, controlling the output and other cool things.

Writing or Editing Tests

Tests are seperated into TestCases, each TestCase will test one unit. Examples of units are models, pages and forms. Refer to PHPUnit’s documentation for specific details on how to write tests.

It’s very easy to write useless tests, some pointers to avoid doing so:

  • Before writing tests, write a Doc Comment description before the Test Case explaining why the test exists.
  • Write descriptive names for tests, similar to a Doc Comment these force you to think about what and why you’re testing.
  • You’re supposed to write tests that fail, this means running it so you can see it fail, then fix the code to make it pass. It’s important to remember that you must change the code being tested, not the test itself, for this.

For the sake of maintainability put as much care into reusing your test cases code as any other code, without violating these:

  • TestCases should never be dependant on another Test Case, individual tests can be when it makes lots of sense but it should be avoided. The reason is so that (for speed) you run a subset of the tests (hence the name Unit Test).
  • Factory methods (such as getEmptyUser() or getYoungUser()) should be begin with “get” and placed at the bottom of the class. They’re used to make maintaining easier.

More Information

PHP Unit Docs:
Advice on writing tests:



Sat here as Alex fertilised the forest gives me a short break from both our footsteps and our nattering.

I read my Lonely Planet a little before scolding at myself and just listening. Slowly at first, much like your eyes adjusting to the brilliance of the stars the volume slowly increases until the buzzing of bugs is only interrupted by birds chirping and trees rustling – and the odd fool with his MP3 player going, I politely reminded him I’d go to a disco if I wanted music. Turns out he works there, but what does that matter? That’s even more reason he should follow the “No Music” sign – which also forbids a small dictionary’s worth of other things.

Three weeks later, I finished writing this

Tikal is an awesome place, I’d love to have been the first person to write about it because it’s such a cliché. Walking down jungle paths between pyramids, climbing up them to peek at the tops of others poking out the trees.

Yada yada, I loved it but we had a different mission.

Yavin IV

Tikal, you see, was the set for the rebel base in Star Wars IV.  A fact pointed out by Steph (or Paola, or both perhaps) a few weeks earlier during our Star Wars Marathon.

So here we are on a mission to find X-Wings and support the rebel cause. hmm perhaps not sensible words to be using in these politically unstable countries!

Temple IV is the one used, though the noise of the X-Wings must have rustled the feathers of the much animal life (including Toucans!) we saw later that evening as we waited for the sun set.

Heading out as the light rapidly faded every leaf became a terrifying spider. We ducked into a bat cave (not knowing it was one until we reached the end) and finally got back to our hotel – El Jaguar- where we had rented a tent in their garden, and whiled the evening away drinking Micheladas and eating expensive pasta.


The next day we headed to Flores, I’d made a careful list of all the great sounding coffee shops, drinking establishments and food places I wanted to visit and Alex had agreed to a crawl of the lot of them. Unfortunately a truck ran into a power line and the whole of El Petén was out of power, so most places closed down. We whiled away the evening in our hostel, Hostel Las Amigos, and I had the chance to visit the well-worth-the-wait Cool Beans in the morning for breakfast. After breakfast I bought an excellent new book which kept me entertained during the 7 hour bus journey back home.

Passover Abroad (why on earth do I not drink beer?)

While I’m at home, living comfortably at dad’s, Passover abstinence is a relatively simple affair. Matza is in abundance, the kitchen is familiar and the local availability of produce well known.

This is my second Pesach while travelling, the first I was in Israel for the first day. I quickly got out of there because their [Major generalization warning] idea of Passover is to simply make awful bread rise with something other than yeast – but my gripes with the Orthodox are not the point of this post.

The easier food is, the less you think about it. So in England my family tends to avoid bread, marmite, pasta, beer and anything obviously leavened (we are not a family who thinks “Levaning Agents” is kosher just because there’s a Rabbi somewhere who wants carrot cake at the seder). There’s some weird ones, however. Neither Marmite nor beer are leavened and pasta doesn’t even contain yeast. Yet we avoid them, but why?

While abroad I’ve had the opportunity to rethink my Passover adherence and to decide what I should do, what really doesn’t matter and why I do it. I have decided to avoid Bread, Churros and Beer. It’s been several years since I considered Marmite not Kosher for Passover, this year and in this circumstance I have decided that Tortillas are Kosher for Pesach. Not that it matters, since your Judaism is yours and mine is mine, but here’s why.

We do it, because our grandma did

This is the real reason for most Jewish traditions. We come up with all kinds of symbolic reasons and even find biblical references for most traditions, but the real reason we do what we do is because that’s what makes us Jewish. However un-Jewish we may think we are are the very fact we identify as a Jew makes us 100% more Jewish than everyone else.

Making an effort is what makes us Jewish

Identifying as being Jewish can be quite an effort, though doing what it takes to feel like a Jew (and so to identify as a Jew) takes even more effort. Judaism isn’t a religion for the lazy or the shy, most of our traditions are in place to show our Judaism to those around us – from the curly whirlies of the orthodox to the Chanukah Parties decorated with cheap Christmas lights of the liberal. Jews are a proud people with fun traditions that many gentiles enjoy partaking in.

I’m a Jew, yeah!

This week I am not drinking beer or eating bread because that’s what makes me feel Jewish. I could avoid wine that hasn’t been commercially blessed as “Kosher for Passover” but that wouldn’t make me feel any more Jewish than saying a blessing before using the toilet. I don’t entirely eat Matza to remember my ancestors in the desert, because my ponderings of the previous years have lead me to question the historical accuracy I used to take for granted. I eat Matza because I am a Jew, and that’s what Jews do at this time of year. Each and every one of the 13 million other Jews out there may do something different for Passover, but that makes no difference to my Judaism.

A by product of my adherence is the remembering of and opportunity to retell the story of the Jewish people, a story I am very proud to be in the cast for the latest chapter of.

This post was inspired by videos such as the following:

Photo Credits:

The Travelling Geek

The Destination:

Aside from the Live USB sticks, this post is only Windows related.

The Journey:

The first few weeks I spend trying to travel and keep up some web development were laborious, and some lessons have been learned. I hope that this post can help someone else to avoid the time waste I have – though my experience has shown this to be a very touch and go way of working.

The Conclusion: Buy a Laptop

After a few months of working this way, I bought a second hand laptop in Mexico City. An HP Mini with an 8inch screen, 160GB hard drive and a few weeks later an extra battery (giving me about 8-10 hours life). I found that using the setup described here had too many shortcomings, including not being able to make use of the dozen-hour-long-bus journeys.

I loved my little Bubbles, but while sailing on The Wong I broke her screen. And then again, until my 8 inch screen was less than 6 inches. That’s when the VGA chip died.

Despite the extra cost, having a laptop meant I could work without having to ask my CouchSurfers for their computer, I could work in coffee shops and Cafes and on buses (charging when we stopped for lunch).

The Other Options:/h1>

Live USB Stick

I’ve concluded that a live OS on a pen drive is simply not stable, I’ve tried various versions of Linux (unfortunately I didn’t keep track of which they were, but Ubuntu 10.10 was included). From being troublesome to install to suddenly giving up after a few days, I have had no long term joy. I’m only an amature Linux user, so perhaps someone who can dig deeper into the config may have more luck.

Portable Apps

When using portable apps I highly recommend using a menu system for it, there’s a few around. The first I tried was SmithTech Portable Menu, about which I have no complaints: it’s fast, flexible and easy to use. However I switched to LiberKey because:

  • Their software catalog makes it silly easy to install applications.
  • The software in the catalog has been well modified to run portabley, in contract to some which work but are not quite portable.
  • You can still add your own applications, not from their catalog
  • You can split the menu between tabs (or categories)

I’ve disabled the animations and some of the other resource heavy pretty things, and made the menu single click instead of double click and am currently loving it.

I’ve tried about a dozen apps from and found them to be cheaply packaged and messy. I don’t even try them anymore unless I can’t find a well packaged or alternative piece of software.


Before I left to go travelling I spent some time wrestling with different WAMP setups. Wampserver is my preferred choice at home, however it doesn’t do portable very well.

I settled with Uniserver in the end, despite disliking some of it’s workings to begin with, the new version (8.0) makes things much easier (if slower).

I found running my DocumentRoot from my USB was too slow. So I now have a folder (which I call www) which I copy to c:\temp before getting going. It’s not as neat as running it all from the USB, but it’s fast enough to work from.

Document Root
With UniServer on my USB, and added an icon to LibreKey, and pointed the document root at c:/temp/www/public.

I edited my.ini to tell MySQL to use c:/temp/www/data/mysql instead of it’s default folder on my USB.



Teotihuacan, not only can I now pronounce it but I can spell it too!

I’m not really sure what to say about it, it’s just awesome. That and we don’t actually know an awful lot about it.


We know it’s old, it was probably started around 200BC though we have no idea by whom. It was all over by around 600AD, shortly before the Aztecs found it and thought it the place where the gods had lived.

At it’s height, around 450AD, it had around a population of around 200,000 and was probably the largest city in the world at the time.

It’s about 2 hours drive, and then several more hours walking around in awe, and clambering up the 234 steps of the Pyramid of the Sun. Which archeologists now think was actually dedicated to the rain god, not the sun god.


The view from the top of the Pyramid of the Sun was amazing, in every direction you look there’s mountains (being in the Mexican Basin and all). You can also look down upon green grassy mounds covering not yet restored pyramids and other structured from the old city. To the north is some ugly urban sprawl clambering up the mountain, which sucks – but nothings perfect.


Also cool is the Pyramid of the Moon, much smaller but due to it’s having larger steps actually harder to climb. It’s located next to a large plaza and was probably used more by the plebs, with the Pyramid of the Sun being for the priests and important people. So, predictably, I prefer the Moon 🙂


Also surrounding the main attractions are the ruins of the city: houses, offices, plazas and soap boxes (allbeing huge ones made from stone) – and many of the walls still reatin a faded remenant of their original paint work. So with a little imagination, you can take yourself back and imagine getting ready to go watch the latest human sacrifice tumble down the side of the Pyramid of the Sun.


IMG_9202.JPG IMG_9238.JPG