Installing and Configuring Laravel on Windows, Linux, and Mac

Ronaldo B.August 1, 20223 min read

In this article

In this article, we will learn what Laravel is and how we can install and configure it on various Operating Systems.

What is Laravel?

Laravel is one of the most well-known and widely used PHP frameworks today. Famous for its very organized folder structure and elegant syntax, its usage and popularity have grown significantly in recent years.

Its project is Open Source and provides us with many advantages. Its ecosystem is filled with tools that facilitate the development of our applications. Some examples are the routing system, template system, and amazing features for Databases, such as Migrations, which are like a “version control for Databases.” With Laravel, it is possible to create, delete, and add data to tables using only code, without needing to go to the Database.

Through these conveniences, many programmers have realized that repetitive, routine codes or processes that took them a long time to develop can be executed with Laravel in just moments. It is truly very practical. With Laravel, we can create an entire PHP application, or an API that will be consumed by another technology, such as Angular, React, or Vue.

The Laravel community is very active and its documentation is quite complete, which shows that this tool has excellent support for those who wish to learn it.

Installing Laravel

To install Laravel, you need to have Composer already installed. If you do not have Composer on your computer, you can see how to install it in this video on our YouTube channel: Composer - Learn how to install and configure this dependency manager.

Additionally, you need to have PHP configured on your computer, with version 7.2 at a minimum.

Unlike most tools, which have a distinct installation for each Operating System, Laravel can be installed on Windows, Linux, or Mac with the same command. Incredible, don't you think?

We will be working with the Terminal in this article. It can be the Command Prompt in the case of Windows, or the default Terminal in Linux and Mac.

After opening it, and remembering the importance of having Composer installed on our computers, we will execute the following command:

composer global require laravel/installer

It will use our Internet to download and install Laravel. After that, Laravel will already be available for us to use.

It is also very simple to create a project in Laravel. Let's do that now.

To create a project, we will again use the command line. We can open the Terminal wherever we want. In my case, I will open it on the Desktop. We will execute the command laravel new and then we will provide the name of the project we are creating. The command will look like this:

laravel new hcode-project

The creation process will start, and after a few moments, we will see the message that is in the image below:

Message in the Terminal about the project creation with Laravel

Laravel will have created for us a folder called hcode-project, which is the name of our application. We now need to enter this directory through the Terminal. To do this, execute the following command:

cd hcode-project

If you open this directory in your Text Editor, you will be able to see the entire folder structure of Laravel. To start our application, just execute the command below:

php artisan serve

We will see the following response in our Terminal:

Terminal running our server

It informs that our server has started successfully and is available on port 8000 of localhost. By accessing the address http://localhost:8000 in the browser, we will see the following:

Laravel project rendered in the browser

Our application is already started and ready to receive more resources :)

As we mentioned at the beginning, one of the main advantages of using Laravel is that it is a framework with elegant or eloquent code and can be used to create robust and powerful applications in less time. It will certainly continue to grow even more in the coming years.

Remember that we teach the concepts of this elegant framework in our course Creating REST API with Laravel 5.7, where we create an API using Laravel's resources.

Until the next article :)

Keep learning with Hcode

Sign up for the course platform and follow the next blog guides.