Set up Laravel 5.4 with MAMP Pro on MacOS Sierra

I regularly need to work on WordPress sites locally on my laptop, and for me nothing beats the convenience of MAMP Pro. I’ve also been working on some projects in Laravel, and so needed to add that to my local set up. There are many ways to do this, including Valet and Homestead, both of which are provided by Laravel. However, I didn’t need the power of Homestead and the last time I tried setting up Valet alongside MAMP I ended up with a mess of conflicting versions. In trying to unravel that mess I pretty much totalled my Mac install.

After wiping and reinstalling my Mac, I decided that I would try setting up Laravel to work with MAMP Pro. I couldn’t find an up to date set of instructions that covered every step, so I’ve put this here for my own future reference and in in case it’s useful to anyone else.

I’m using Laravel 5.4 and MAMP Pro 4.1.1 on a clean install of MacOS Sierra 10.12.5.

1. Set bash to use the MAMP version of PHP

The version of PHP that comes preinstalled on MacOS is out of date, so the first thing to do is to make sure that we are using the version installed with MAMP.

export PATH=/Applications/MAMP/bin/php/php7.x.x/bin:$PATH

Replace 7.x.x with the version of PHP you want to use in the terminal.

2. Download and install composer

Laravel uses Composer, so we need to downlad and install that:

curl -s http://getcomposer.org/installer | php

And then move it and set up an alias (see note at the end of step 4). I’m using nano, but use your editor of choice.

sudo mv composer.phar /usr/local/bin/
nano ~/.bash_profile

Add the following to the .bash_profile file.

alias composer="php /usr/local/bin/composer.phar"

Restart the Terminal, and you can run Composer by typing:

composer

3. Install Laravel using Composer

Now we can install and set up Laravel.

composer global require "laravel/installer"

Note: On a clean install, you will be prompted to install the Xcode command line tools (if you haven’t already done so).

4. Make the laravel command available

So that the system can find the Laravel executable we need to run:

echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile
source ~/.bash_profile

Note: At this stage trying to use the laravel command produced an error saying that composer could not be found. Following advice in this thread on Laracasts I renamed composer.phar to composer and updated the alias.

sudo mv /usr/local/bin/composer.phar /usr/local/bin/composer
alias composer="php /usr/local/bin/composer.phar"

5. Create a Laravel project and make it available via MAMP Pro

Create a new Laravel project

cd ~/Code
laravel new blog

Edit 20 Sep 2017 – Thanks to Sergios who found that these additional commands were needed to get things working.

cd blog
composer install
php artisan key:generate

In MAMP Pro we create a new host (I chose blog.dev) and then point the root to the public folder inside the Laravel project. I also chose to let MAMP Pro create a new database named ‘blog’.

MAMP Pro hosts screen showing blog.dev set up

Start the MAMP Pro servers and the site should be accessible at http://blog.dev

A blank Laravel app running in Safari

6. Using MAMP’s MySQL

If we want to use a database with our app we need to add the details to the .env file:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=root
DB_PASSWORD=xxxxxx

Note that we’re using localhost rather than 127.0.0.1. If you want to use 127.0.0.1 you need to set MAMP Pro to ‘Allow network access to MySQL’ on the MySQL settings screen.

The MAMP MySQL settings screen

When you run php artisan migrate you may see this error:

[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

This seems to be caused by the version of MySQL that MAMP Pro uses. Following advice in this thread on Laracasts I added the following to AppServiceProvider.php:

use Illuminate\Support\Facades\Schema; //Add this to the top of the file

public function boot()
{
Schema::defaultStringLength(191); //Add this line to the boot function
}

If we delete the tables created in the previous attempt and then run php artisan migrate again, it should now work and you should see a message similar to this:

Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table

Now that everything is set up we should just need to follow steps 5 and 6 each time we want to create a new Laravel project.

On the long slow death of Twitter

I came across this great cartoon in The Guardian over the weekend. It sums up much of what I think about Twitter – except for the final frame.

The cartoon uses the analogy of Twitter being a bar and concludes by wondering if “maybe it’s time to find another bar.” For me, Twitter feels more like that bar you went to at a certain time in your life, but now you have other things to do. You look back at it with good memories, but you don’t need to replace it.

Beautifully Packaged

BookArc for Air
Photo credit:Yusuke Yamanda

twelvesouth make beautiful products, one of which is the BookArc, and my Macbook Air sits in one on my desk. It’s in my field of vision all day, so to me it’s important that it is beautiful. However, this post isn’t about the book arc, it’s about the box it came in.

They could have sent it out in any sort of packaging, a plain brown box, glossy printed cardboard or even one of those awful, impossible to open plastic bubble things. They didn’t. Instead they chose to use beautiful packaging to go with their beautiful product.

Inside the box, as part of the instructions they say this;

12 ways to re-purpose your BookArc box:

Our flag is red and our hearts are green. So if you could, do the earth a favor and use your BookArc in a fun new way.1

  1. store stationery and prove people still write letters
  2. use one tray as an inbox, the other as an outbox for bills
  3. plant wheat grass in the lid for a modern turf table piece
  4. cut a slit in the top to use it as a personal “suggestion box”
  5. cut a slit in the top and use it as a sweet box for Valentine’s cards
  6. use it as a treasure chest for kids
  7. turn it into kindling for a romantic fire
  8. fill it with pens, pencil, crayons and markers
  9. put a gift inside it and mail it to a friend
  10. use it in the garage to store nails, screws and other small items
  11. flatten it out and use it as a backer board in a picture frame
  12. let your kids use it for their next craft project

Now I’d like you to consider two things:

If everything came in beautiful packaging – would you still find it as easy to dispose of, or would you be more likely to reuse it?

If you paid that much attention to the way your work was packaged, how much better would the finished product be?


  1. My box contains concert tickets, Glastonbury wrist bands and even my badge from the first time I spoke at Learning Technologies.

How Far Would You Walk for Water?

Mariama collecting water

Mariama carries the orange and yellow bucket

Photo credit: WaterAid/Layton Thompson

“Mariama Oumara Dicko lives in an isolated village in Mali. Scarce water supplies during the dry season forces her to go out three times a day, every day, to collect dirty water from manmade ponds. Each journey takes three hours.”

March 22nd is World Water Day 2011. Across Africa, people spend between 3 and 10 hours a day collecting water. It is usually down to women and children to collect water, stopping them from gaining an education or earning a living and taking precious time that could be spent making permanent improvements to their circumstances.

What would you rather be doing?

WaterAid have put together a list that compares the time spent on typical activities in the UK to the time spent collecting water in developing countries:

  • Let’s get social: In the UK, people spend an average of five hours 48 minutes on social networking sites per week (comScore). In Sub-Saharan Africa, that’s two trips to collect water. What would you rather be doing?
  • I say! The average man will spend five hours a week staring at different women (Kodak Lens Vision Centres). In one week, the average woman in a developing country would have spent 21 hours collecting water.
  • Wedding bells: A bride-to-be spends an average of 250 hours preparing for a wedding. For a woman in Africa, that time could be spent making 83 trips to collect water. You can bet she’d rather be planning her big day!
  • Goal! Mr Average in Britain spends six hours and 12 minutes a week watching, talking about and keeping up-to-date on football (BT Vision). After that amount of time, a woman in the developing world could be making her third trip in one day to collect water.
  • Break a sweat: The average adult exercises just 50 minutes a week (WeightWatchers) – less than a third of one trip to collect 20kg of water.
  • Off to the shops: The average British woman spends 94 hours and 55 minutes shopping for food over one year, and more than 100 hours shopping for clothes (OnePoll). Women in sub-Saharan Africa spend the same amount of time collecting water in just one month. This time could be much better spent growing or selling their own food.
  • School’s out: It takes a mighty 3,600 study hours to complete an Open University Honours degree. That’s little more than three years spent fetching water – time better spent on education.
  • Beep, beep! It takes, on average, 47 hours of driving lessons to pass a driving test in the UK (DirectGov). In the same amount of time, millions in Africa will have made just 15 trips to collect water – and they won’t be making those journeys by car.
  • On track: The average daily commute in the UK takes 47 minutes and 48 seconds (TUC). It might feel like 47 minutes too many, but it’s still less than a third of the time it takes to collect water in sub-Saharan Africa.
  • A nice cuppa: We spend about six hours a week drinking tea and coffee (LearnDirect). That’s two trips to collect water, with no coffee break.

Call To Action

Access to clean, safe water doesn’t just save lives. It is essential to improving education, health, gender equality and economic growth.

Please take the time to sign WaterAid’s petition urging Government to take action to stop the water crisis.

Dig Toilets Not Graves

Barry with WaterAid tattoo at Glastonbury

Today is Blog Action Day 2010, and the subject which was chosen by popular vote, is water.

I’d like to talk about WaterAid, a charity that I first heard of through the Glastonbury Festival, where they are one of the three ‘Worthy causes’ alongside Oxfam and Greenpeace (hence the accompanying picture of me in silly hat from this year’s festival). You can read more about WaterAid at Glastonbury here.

What’s the problem?

Nearly a billion people around the world have no access to safe drinking water.

4500 children die every day because they lack safe drinking water and basic sanitation.

Many children, particularly girls, get little or no education because they are often expected to collect water for the family.

Ensuring that everyone has access to safe water and sanitation is the first step to eliminating global poverty and social exclusion.

What does WaterAid do?

WaterAid works with partners around the world to provide practical solutions to provide safe water and effective sanitation to the poorest people around the world.

They also provide hygiene education and follow a community led approach that ensures that they work with the people they are helping, to provide sustainable solutions that belong to the community.

They publish research and policy guidance as well as developing standards of governance and accountability.

The Dig Toilets Not Graves Campaign

Have you ever been caught out, away from home and needed the loo? The chances are you have, but that you very quickly found a toilet somewhere nearby. In fact, there are so many toilets in the UK that you can even load up a free iPhone app from WaterAid that will locate your nearest public toilet.

Contrast this with the 1,500,000 children who die each year through lack of sanitation. In areas without toilets, human faeces contaminates water and food and leads to the spread of deadly diseases.

The tools and education provided by the The Dig Toilets Not Graves campaign can help to stop this situation. You can find out more here.

How can you help?

There are many ways that you help WaterAid to achieve their goals.

  • Look for them at events from Glastonbury to the Great North Run
  • Take part in their campaigns and offer your support as they lobby decision makers across the world
  • Get involved as a volunteer, organising events or fundraising
  • Or simply make a donation

If you’re a large organisation, please think about the opportunities for corporate sponsorship and partnering.

Poetry Heroes

Today in the UK it is National Poetry Day and the subject is heroes and heroines, so I thought I would take the opportunity to post one of my favourite poems, written to honour the pilots who flew in the Battle of Britain.

Fighter Pilot

He was no Galahad, no knight sans peur et sans reproche.
Sans peur? Fear was the second enemy to beat.
He was a common, unconsidered man, who, for a moment of eternity,
held the whole future of mankind in his two sweating hands.
And did not let it go.
Remember him, not as he is portrayed, but as the man he was.
To him you owe the most of what you have and love today.

Air Chief Marshal Sir Christopher Foxley-Norris

Different is Memorable

Whether for holidays or business, flying is one of those things that has become so common that we rarely give it any thought. In particular, most people give the appearance of ignoring the pre flight safety briefing. So if you want people to pay attention and learn, it makes sense that you should do something uncommon.

That’s exactly what Thomson have done, and on a flight with them last week, I would estimate that 90% of the people on the plane paid attention to the whole thing.

Want to know why? Watch the video.

Tweet Psych

Just ran myself through Tweet Psych. Not entirely sure what this says about me, but here are the results;

Cognitive Content

  1. Present tense
  2. Positive emotions
  3. Tentative
  4. Future tense
  5. Upward motion
  6. Insight
  7. Senses
  8. Past tense
  9. Cognitive processes
  10. Space
  11. Occupation & work
  12. Motion

Primordial, Conceptual and Emotional Content

  1. Abstract thought
  2. Social behavior
  3. Constructive behaviors
  4. Concreteness
  5. Glory
  6. Restraint
  7. Anxiety
  8. Visual sensations
  9. Order
  10. Positive affect

Why not give it a try?

Facebook and democracy

It’s a sign of  how quickly things move in the field of social media, that I was half way though composing a post about content licensing and the recent furore over Facebook’s changes to their terms of service, when what should pop into my feed reader, but another bombshell from Mark Zuckerberg and co. Only this time, they seem to have got it right, or at least they intend to.

This post on the Facebook blog outlines what they intend to do. Essentially, they plan to take a more democratic approach, giving members the opportunity to comment and vote on changes to the way the site is managed. They’ve made a start by inviting comment and discussion on two documents that would become the foundation of the new way of working; the Facebook Principles and the Statement of Rights and Responsibilities.

Of course, only time will tell how well this new approach works, and that will depend both on Facebook’s commitment to these principles, and the user’s willingness to engage with them in this way.

You might be cynical and say, “hey, isn’t this just another big company screwing up and now desperately back pedaling?”, but for me, this is what web 2.0 is all about. Things change rapidly and as a result companies like Facebook sometimes get it wrong, but I can forgive them this as long as they keep listening, learning and changing. Better that than the over cautious, focus group obsessed approach of 20th century business.