Tech Hub

Laravel

Laravel Framework Installation on Windows & Linux

Laravel, one of the best PHP framework is becoming increasingly popular with developers around the globe. Laravel was made simple and powerful by the Model-View-Controller architecture and the blade templating engine. Here we'll cover the installation of Laravel on Windows and Linux.

  • Requirements to Install Laravel
  • What is Composer?
  • Download & Install Composer in Windows
  • Creating New Laravel Project using Composer
  • How to Run the Laravel Application
  • Download & Install Composer on Linux
  • Install Laravel on Ubuntu
  • Running Laravel Application 

Requirements to Install Laravel

Before moving to the Laravel installation, we must ensure our system meets all the following Laravel application specifications.

  • PHP >= 7.2.0
  • BCMath PHP Extension
  • Ctype PHP Extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension
  • Composer

If you use any WAMP, XAMPP or Laragon program on your system, all the above specifications will most likely be enabled on your system except the Composer.

What is Composer?

Composer is a dependency manager for PHP. It is a simple and reliable tool that developers use in their PHP-based projects to manage and integrate external packages. With this in hand, they don't have to create their web pages or web applications from the ground up.

Download & Install Composer in Windows

First of all make sure that you have PHP and MySQL installed and running on the machine/system before installing Composer. To check this, open the command line terminal (Git Bash or Windows Command Terminal) and execute the command below.

 

If  PHP is installed and running properly, you will get the following output.

 

Next is the downloading of the latest edition of Composer for Windows from the official website. You'll get the link to download the Composer-Setup.exe file in the Download section of the Composer website.
Once downloaded, run the composer’s installation file. Simply click Next, you will have the installation window open as below.

 

The installation will then automatically locate the installed PHP on your computer, click Next.

 

You will be asked for any proxy settings, as shown below.

 

Upon clicking next, composer’s install screen will appear. Press Install to finish it.

 

Once the installation is complete, open the command line terminal and run the composer. If the composer has been downloaded successfully, you will get the results as shown below.

 

Creating New Laravel Project using Composer

Open the Windows command line terminal like Git Bash or PowerShell, and run the following command to create a new Laravel project.

 

This process takes some time to install all of the libraries and dependencies. The results are shown below.

 

Wait until the cycle ends.

How to Run the Laravel Application

Once the Laravel project has been built, your next app development can be initiated. To switch inside the project folder, run cd mylaravelpro within the command line terminal.
Start the built-in PHP server to run the Laravel application. Open the terminal command line, and execute the following command.

 

The above command will launch the Laravel Development Server. After that, open your browser and visit the localhost:8000 to access the project.

Download & Install Composer on Linux

Installing Composer on Linux needs verification of PHP being installed and running on your system. To verify this, run the php -v command, which will output the version of PHP that you are using on the Linux OS.
You have to upgrade the Linux libraries and packages before downloading the Composer. Run the following command to update the Linux system.

sudo apt-get update

Now, use the utility curl to install the composer.

sudo apt-get install curl

Then run the Composer Update command as below.

curl -s https://getcomposer.org/installer | php

The command above will download the package composer.phar into the directory /tmp. The composer needs to be run globally so you will have to transfer the file under the name composer to /usr / local / bin/ directory.
Execute the command below for transferring the file.

sudo mv composer.phar /usr/local/bin/composer

You can now run the composer from anywhere as it has been deployed globally. Test the composer in the terminal and type composer.

composer

The outcome will be the same as it was while installing for windows.

Install Laravel on Ubuntu

Navigate to the public html directory first. As Apache is being used, so the /var / www / html directory should be activated. Type the following command in the terminal to navigate to /var / www / html.

cd/var/www/html

Once this is completed, create a new project by installing Laravel with the following command.

sudo composer creat-project --prefer-dist laravel/laravel mylaravelpro

Running Laravel Application

When you've completed project creation, use the following command to run the Laravel project.

php artisan serve

After that, open your browser and access the project in your browser window by visiting localhost:8000.

If you are looking for any custom solutions in Laravel, Contact us. 

Share Linkedin