Laravel is a PHP framework used to build Laravel applications. Before creating your first application with Laravel, make sure you have PHP and Composer installed. Composer is used to install Laravel. In this post, I’ll show you how to install Laravel from start to finish.
Setting up a Laravel environment
There There are several 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 will use XAMMP to install PHP, then configure Laravel manually.
Steps for installing Laravel
Installing Laravel can be done in three 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:
To create Laravel applications, we first need to install PHP and MySQL on our machine.
Other ways to install PHP and Composer
These two articles will show you how to install PHP and Composer.
How to install XAMPP on Windows
To create 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 is better to use MAMP, which is compatible with the new M1 and M2 chips.
Now let’s 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, i.e. the one at the bottom of the list.
1. Setup Wizard
Double-click the installer, then follow the instructions.
2. Installer settings
You will not need to change any of the installation settings – the default settings are all good as is.
3. Installation folder
Of particular note, you should leave the installation drive as
C: drive on Windows for things to work properly.
You may also need to grant approval for XAMPP’s Apache installation to have network access through Windows Defender or any other firewall you are running.
4. Control Panel
Continue following the instructions. After the installation is complete, leave the option selected that says Run Control Panel now? Then close the installer and you will see the XAMPP Control Panel appear.
If you missed a chance to leave that box checked, run XAMPP from the list of installed software to launch the Control Panel.
1. Install Composer
Click download Composer-Setup.exe (for Windows) or the equivalent for your operating system. Run the installer and it will install the latest version of Composer.
2. Adjust the system path
Add the PHP executable to your system path using the installer.
3. Proxy server configuration
If you don’t have a proxy server, click Next.
Composer is now ready to install and the installation wizard will download the files to your computer.
You want to be sure that Composer will run smoothly.
Open command prompt or terminal and run the command
composer --version. You should see the current version of Composer printed on the terminal.
How to install Laravel
1. Open Terminal
Now that you have PHP and Composer installed, creating a Laravel project is simple. Open your terminal.
2. Create a Laravel project
Run the following command to create a new project inside a folder named my-app (or any project name you want):
composer create-project laravel/laravel my-app
This will download all the Laravel files needed for this project.
3. Start the development server
After the application is built, cd into my-app and start your development server using the following commands:
cd my-app php artisan serve
4. Switch to your new Laravel app
We have finished configuring the environment. You should be able to access your Laravel development server at https://localhost:8000.
That’s it – you’ve successfully installed Laravel and run your first app. But that’s 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 start learning Laravel is with a free course from Envato Tuts+.