Get your next remote job on LaraJobs.

How to install Laravel on macOS

How to install Laravel on macOS

Introduction to installing Laravel on macOS

So, you finally decided to give Laravel a try.

But how do you even get started? Well, first, you must have a working PHP environment (see how to install PHP on macOS). Then, you must create a new Laravel project using the official Laravel installer or Composer (the package manager every PHP developer uses to manage dependencies).

Feels overwhelming? Don’t worry. In this article, I’ll show you exactly how to do that.

How to install Laravel on macOS

Using Composer

To install Laravel on macOS, Linux, or WSL, you can create a new project using Composer like so (given you already have a working PHP environment):

composer create-project laravel/laravel example-app

Then, you can just cd into your project and start the development server:

php artisan serve

Finally, open http://localhost:8000 in your browser.

But installing Laravel using Composer is limited and I will show you a better way.

Using the official Laravel installer

Laravel offers a convenient installer that you can add to Composer’s global packages using the following command:

composer global require laravel/installer

Then, you can create a new project:

laravel new example-app

If this command doesn’t work, make sure you followed my guide correctly.

The Laravel installer even offers options to create a new initialized Git repository with a first commit without having to go through the various prompts:

laravel new example-app --git

Or even use Pest as a default test runner:

laravel new example-app --pest

And you can combine these:

laravel new example-app --git --pest

There are a ton of options and you can see them all by running laravel new --help:

Description:
Create a new Laravel application
 
Usage:
new [options] [--] <name>
 
Arguments:
name
 
Options:
--dev Installs the latest "development" release
--git Initialize a Git repository
--branch=BRANCH The branch that should be created for a new repository [default: "main"]
--github[=GITHUB] Create a new repository on GitHub [default: false]
--organization=ORGANIZATION The GitHub organization to create the new repository for
--stack[=STACK] The Breeze / Jetstream stack that should be installed
--breeze Installs the Laravel Breeze scaffolding
--jet Installs the Laravel Jetstream scaffolding
--dark Indicate whether Breeze or Jetstream should be scaffolded with dark mode support
--typescript Indicate whether Breeze should be scaffolded with TypeScript support (Experimental)
--ssr Indicate whether Breeze or Jetstream should be scaffolded with Inertia SSR support
--api Indicates whether Jetstream should be scaffolded with API support
--teams Indicates whether Jetstream should be scaffolded with team support
--verification Indicates whether Jetstream should be scaffolded with email verification support
--pest Installs the Pest testing framework
--phpunit Installs the PHPUnit testing framework

Be the first to comment!

Get help or share something of value with other readers!

Great deals for enterprise developers
The latest community links

Recommended articles

PHP for Mac: get started fast using Laravel Valet

Use your Mac as an ideal PHP environment thanks to the power of Laravel Valet. You can finally say goodbye to Docker!

Laravel 10 is out! Here are every new features and changes.

Laravel 10 has been released on February 14, 2023. Let's dive into every relevant new features and changes.

20+ Laravel best practices, tips and tricks to use in 2024

Learning a framework can be overwhelming, but time and execution will make you a master. Here are some best practices to help you toward your goal.

Laravel 11: the big changes ahead and release date

Laravel 11 will be released on February 6th, 2024. Its development is still ongoing. Let's dive into every relevant new feature we know about already.

Laravel 10: the upgrade guide from version 9

I show you how to upgrade your Laravel 9 project to version 10 and help you decide whether the return on investment is worth it.

Laravel 9: the mindful upgrade guide

I show you how to upgrade your Laravel 8 project to version 9 and help you decide whether the return on investment is worth it.

A complete history of Laravel's versions (2011-2024)

What's the current version of Laravel? Is there any LTS release you can rely on? And what about the history of the framework? Let's find out!

- / -