This is my first post on the Laravel 6 series. From, today, I will be posting the tutorials on the most popular PHP framework. Recently, the laravel has released the latest version which is Laravel 6. It is more robust and secure. Currently, it is released in the LTS (long term support). That means the bugs fixings and the security fixings will take a long while. So, I am going to start with laravel installation. I am going to show you the step by step process of the laravel install in windows and ubuntu platform. We’ll download composer first.
- 1 Composer – Install Laravel
- 2 Requirements to Install Laravel
- 3 Download and Install Composer in Windows
- 4 Laravel Install – Create New Laravel Project in Windows
- 5 Open Laravel Project
- 6 How to Run the Laravel Project
- 7 Install Composer in Ubuntu
- 8 Install Laravel in Ubuntu
- 9 Conclusion
Composer – Install Laravel
Laravel requires the composer for managing and controlling the dependencies in PHP.
- A composer is a tool that allows you to declare the libraries that are required by the project.
- Basically, it is a package manager that provides the standard format of dependencies management in PHP.
- It is an open-source tool and free to use.
Requirements to Install Laravel
Before moving to the laravel installation. Please make sure you have followed the below requirements.
- The Laravel 6 requires PHP >= 7.2.0 version.
- An OpenSSL extension enabled for the PHP.
- BCMath PHP Extension in the PHP.
- Ctype PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
Download and Install Composer in Windows
- Before, downloading the composer, please make sure you have the latest version of PHP (7.2). If you haven’t installed PHP and MySQL then it is highly recommended to go through the installation and configuration of PHP and MySQL.
- In the next step, download the latest version of the composer for the windows, from the official website which is https://getcomposer.org/download/
- This is small in the size. Once, you have downloaded, just start the installation process as similar to the other applications.
- Install it globally so leave the rest things as default.
- Now, click on install and it will take very less time to install.
- Once, the composer installation has finished. Open the command prompt windows by pressing (win+r) key.
- Then type composer and hit enter.
- If you got a response like this then that means the composer has been installed successfully in your system.
Now, we’ll be moving to the process of Laravel download and install.
Laravel Install – Create New Laravel Project in Windows
- Open the command prompt windows you can also use Gitbash or PowerShell window.
- Type the following command to create a new project in the Laravel.
composer create-project --prefer-dist laravel/laravel my-first-app
- In the above command replace your project name from
my-first-app. Here, this is the project name that I am going to create in this post.
- This will take some time to install the dependencies, libraries files in the project.
- So, please wait until the process completes.
- Once, the project has been created, you will need to open it in your favorite editor.
Open Laravel Project
- You can open this project in any editor like sublime, bracket, atom or Visual Studio Code. But, I recommend using the VS Code.
- Navigate to your project folder (where laravel project has been created.)
- Hold Shift key then Right-click the mouse and open the PowerShell window.
- Also, you can use the GitBash then you no need to use the shift key. Just right click the mouse, and click on open GitBash.
- Now, type
code ., it will open your project in Visual Code Editor.
- Now, the project has been opened in the VS Code editor.
How to Run the Laravel Project
- Laravel project uses the built-in server of the PHP. So no need to install any server.
- At the top menu bar in the VS Code editor click on the Terminal and then click on the New Terminal.
- It will open the Terminal tab at the bottom.
- Now, type the following command there
php artisan serve
- The above command will start the laravel development server.
- After that, open your browser and access the project by typing the following URL.
You will see the result in the browser as the Laravel default page as shown below.
Install Composer in Ubuntu
Before installing the composer in Ubuntu. Please make sure you have the PHP >= 7.2.0 installed in the system. If not then check the PHP version. Just open the terminal window and type
- If you have the older version than 7.2.0 than I recommend you upgrade the PHP first.
- In the next step update the package of the Ubuntu.
sudo apt-get update
- Now, install the curl utility so that we can install the composer.
sudo apt-get install curl
- Then, type the below command to install the composer.
curl -s https://getcomposer.org/installer | php
- The above command will download composer.phar package in the /tmp directory. But, we require the composer to run global so that it can be accessed from anywhere.
- Therefore, we will require to move it to /usr/local/bin/ directory under the name ‘composer‘.
- So, after that type the below command to move the composer.phar package.
sudo mv composer.phar /usr/local/bin/composer
- Now you can access composer from anywhere because it has been installed globally.
- Hence, check the composer in the terminal and type
Install Laravel in Ubuntu
Now, we will install the Laravel in Ubuntu. First of all, we will need to navigate into the public html directory.
- Actually, we are using Apache, so it should be installed the /var/www/html directory.
- So for navigating into /var/www/html please type the below command in the terminal.
- Once, you are done with this, create a new project with laravel installation by following the below command.
sudo composer create-project --prefer-dist laravel/laravel your-project-name
your-project-name is the project name that is going to be created.
Once you are done with the project creation, run the laravel project using the following command.
sudo php artisan serve
We have installed Laravel 6 with the composer in Windows as well as the Ubuntu platform. For Laravel 6, it requires the latest version of PHP >=7.2. Laravel requires the composer. Basically, a composer provides all the dependencies that require a Laravel 6 application.