Laravel is a PHP framework that is used to build Laravel applications. Before you create your first application with Laravel, make sure you have PHP and Composer installed. Composer is used to install Laravel. In this post, I will show you how to install Laravel from start to finish.
Setting Up a Laravel Environment
There are different ways to install Laravel on your machine, and your choice depends on your operating system. Laravel provides detailed documentation on the different options. The official recommendation is to use Docker Desktop, but in this lesson we’ll be using XAMMP to install PHP and then we’ll set up Laravel manually.
Steps for Installing Laravel
The installation of Laravel can be achieved in 3 easy steps:
- download and install XAMPP (or MAMP for Mac) to get PHP and MySQL
- download and install Composer
- install Laravel with Composer
Watch this video for a complete guide:
In order to build Laravel applications, we first need to install PHP and MySQL on our machine.
Other Ways of Installing PHP and Composer
These two articles will show you ways of installing PHP and Composer.
How to Install XAMPP on Windows
In order to build Laravel applications, we need to install PHP and MySQL on our machine. The easiest way to install PHP on Windows is through XAMPP. It is available on all three desktop operating systems—Windows, Linux, and Mac. However, on Mac it’s best to use MAMP, which is compatible with the new M1 and M2 chips.
Now let’s take a look at how to install XAMMP on Windows.
Go to https://www.apachefriends.org/download.html and download the installer for your operating system. Select the latest version of PHP, ie. the one at the bottom of the list.
1. Install Wizard
Double click the installer then follow the prompts.
2. Installer Settings
You won’t need to change any of the installation settings, the defaults are all good as is.
3. Installation Folder
Of particular note, you should leave the installation drive as the C:
drive on Windows in order for things to function correctly.
You may also need to grant approval for XAMPP’s Apache installation to have network access through Windows Defender or any other firewall you might be running.
4. Gate Fold
Continue following the prompts. When the installation is complete, leave the option checked that says Do you want to run the Control Panel now?, then close the installer and you’ll see the XAMPP Control Panel appear.
If you missed the chance to leave that box checked, just run XAMPP from your list of installed software to start the Control Panel.
1. Install Composer
Click on the downloaded Composer-Setup.exe file (for Windows) or the equivalent for your operating system. Run the installer and it will install the latest composer version.
2. Adjust the System Path
Add the PHP executable to your system path using the installer.
3. Proxy Server Setup
If you don’t have a proxy server, just click Next.
4. Install
Composer is now ready to install and the setup wizard will download files on to your machine.
5. Test
You want to be sure that Composer will run without hitches.
Open the command prompt or terminal.
type and run the command composer --version
. You should see the current Composer version printed to the terminal.
How To Install Laravel
1. Open the Terminal
Now that you have installed PHP and Composer. Creating Laravel is straightforward. Open your terminal.
2. Create a Laravel Project
Run the command below to create a brand new project inside a folder named my-app (or any project name you wish):
composer create-project laravel/laravel my-app
This will download all the necessary Laravel files for this project
3. Start the Development Server
After the application has been created, cd into my-app and start your development server using the following commands:
cd my-app php artisan serve
4. Browse to Your New Laravel App
We are done setting up the environment. You should be able to access your Laravel development server at https://localhost:8000
Next Steps
That’s it, you’ve successfully installed Laravel and run your first app. But this is just the beginning! Now you can learn to build websites and apps with this powerful and easy-to-use framework. Get started with our complete guide to learning Laravel.
Learn Laravel With a Free Online Course
The best way to get started learning Laravel is with a free course from Envato Tuts+.