Unrivaled Creations Stories

Internet Website Design and Bespoke Software Application Development with PHP and the Laravel Stack.

5-Minute Guide to Setting Up Laravel (Mac)

1 year ago · 2 MIN READ
#development  #tips  #laravel 

There are many viable ways to set up Laravel for development on a Mac, each having pro’s and con’s. Let’s just pick one and go!

Set up Laravel with Valet in 5-minutes flat!

Choosing an Environment

As a beginner learning Laravel on a Mac, I noted the wide array of choices available to me for setting up an educational development environment. As an experienced professional developer, I naturally folded Laravel into my existing development infrastructure. But, inspired by the very excellent screen cast tutorial at Jeffrey Way’s Laravel from Scratch, I decided to write a story to show how easy it is to set up Laravel on a Mac using Valet, the environment demonstrated in those videos.

Valet and Laravel Install Steps

These installation instructions will be very (uncharacteristically) terse from here on out. If you need further reference or additional information, please visit the official Laravel Installation and Laravel Valet documentation.

Valet requires macOS and Homebrew. Before installation, you should make sure that no other programs such as Apache or Nginx are binding to your local machine's port 80.

Step 1: Homebrew

Install or update Homebrew.

If you have never used Homebrew before:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

If you have Homebrew already installed:

brew update

Step 2: PHP 7

Use Homebrew to install PHP 7 and (optionally) the xdebug extension:

brew install homebrew/php/php71
brew install homebrew/php/php71-xdebug

Step 3: Composer

Update Composer:

composer self-update

If Composer is not already installed, this command will display an error message. You need to install Composer on your Mac before continuing.

Step 4: Valet

Jeffrey Way’s Laravel from Scratch uses the directory ~/code for the tutorials, so let’s set up this environment to use that, too.

composer global require laravel/valet
valet install
mkdir ~/code
cd ~/code
valet park

Step 5: MySQL

I recommend using MariaDB as your database:

brew install mariadb
mysql.server start
brew services start mariadb

Step 6: Laravel

Finally, install Laravel globally via Composer and create a new app called “blog” in the ~/code directory (where Valet is parked):

composer global require laravel/installer
cd ~/code
laravel new blog

Step 7: Test!

At this stage, you should be able to open your web browser and provide the address blog.dev and Laravel will load the default web page for you.

Next Steps

Did you have any troubles breezing through this 5-minute guide? Comment below, and I’ll be happy to help you out!

Otherwise, visit Jeffrey Way’s Laravel from Scratch tutorial and start learning Laravel.

Happy coding!

···

Michael Hall

Hi! I am a digital product designer and website/web application developer always seeking a better version of myself. Follow my journey as I share my story (and expertise) through the mutable, ever-changing, ever-growing world of design, web development and technology.
comments powered by Disqus


Copyright © 2017 by Michael Hall. All rights reserved. · Sign In