What is Laravel
Laravel is a PHP framework. Learn more from Laravel Official Doc
Install Laravel / Get Started with Laravel
Laravel is a PHP framework and PHP is a language that is used for backend development purposes only.
Unlike JavaScript, which is run on the browser, or on node.js which need to be installed on the computer. All modern browsers have a JavaScript engine like Chrome has V8. So to run JavaScript or get started with JavaScript language we need a browser or Node JS installed.
But PHP runs only on the server, which needs to have server software like Nginx or Apache. Our computer, which is not for server purposes use, does not have any server software, so to run or get started with PHP-Laravel we need to have Nginx or Apache server + We also need to have a Database client like MySQL or PostgreSQL or any other DB system for data storage.
All of this software and more comes with useful Laragon software which gives us a WAMP stack local server environment.
But, Before That
Before installing Laravel we need to have installed and configured both PHP latest version and Composer
Download PHP and configure
- For Windows we need to download thread safe zip file from the official PHP website Download PHP 8.2
- Unzip downloaded file
- Put this unzip file into C Drive > Program file
- Copy that folder path
C:\Program Files\php-8.2.9-Win32-vs16-x64
- Search in the Windows console as
Edit the system environment variable
, it will open the system properties window - Then Click
Environment variable
- In the below system variable section click the
path
option - Then click
New
and put that php path linkC:\Program Files\php-8.2.9-Win32-vs16-x64
- Press Ok Ok Ok and close all windows.
Install Composer
Composer is a laravel package manager.
- Download Composer from official website and Install Composer
- Download this
Composer-Setup.exe
file - When Installing it will automatically detect our PHP file path
If you have composer installed but have an old version. Try to update it to the latest version. For latest version type command and run
composer self-update
Install Laragon
Install Laragon is easy but, keep in mind, install Laragon in D/F Drive, except C drive. If you face any problem with Windows later, then you need to install Windows, and then all of your projects in Laragon will gone!
Download and configure PHPMyAdmin
After installing Laragon we need to download and configure the PHPMyAdmin MySQL DB console.
- Download PHPMyAdmin MySQL from official website
- Put this file into Laragon root www folder. You can go root folder in many ways Or
- Unzip the file and delete the zip file.
- Rename this PHPMyAdmin file for shortcut use as pmad
- Into the pmad folder, rename this config.sample.inc.php as config.inc.php
- Open this file into vs code or any other code editor
- line number 32, make it true
- After that we can get this PHPMyAdmin console from the browser
- But before that, we need to press Stop & Start All Laragon all server and ports
Create Database in the PHPMyAdmin console
- in browser write pmad.test and write username as root, then log in
- Into the pmad console create a db project as you wish, we can write laravel
Enable PHP essentials extensions
Now we need to enable some essential extensions in PHP, without those our Laravel project will not run. These are,
- curl
- fileinfo
- mbstring
- openssl
- pdo_mysql
and more
Go to PHP folder > open php.ini file into code editor > enable these extensions
Install Laravel with Laragon Console
Go ⟶ Menu ⟶ Quick App ⟶ Laravel ⟶ Give name ⟶ Project created
Install with Composer
Laravel uses Composer for dependencies, just like JavaScript uses Node for dependencies. For installing any packages or extensions in PHP-Laravel we need Composer, like npm for node/JavScript language.
- Check composer in command prompt:
composer -v
If Composer is not updated then run the update command
Update composer:
composer self-update --preview
Finally Create a Laravel project with the composer in the Laragon root folder
composer create-project --prefer-dist laravel/laravel myApp
Install with Laravel CLI
Installing Laravel with Laravel CLI is so easy and simple.
- First run this command in Laragon root folder
composer global require laravel/installer
- Then simply install Laravel project by running command
laravel new myApp
After Laravel Install
After installing Laravel we need to configure env file in Laravel
- Copy .env.example and paste a new file as .env
- Now we need to put our DataBase Name, pmad console username and password in .env file
- After that we need to have our project APP_KEY, run Laravel command
php artisan key:generate
- After that need to migrate our PHP table into the Database console, run the command
php artisan migrate
- And Finally we need to open our Installed Laravel project in the browser as
php artisan serve
If you face any problems, email me at mhasan.meet@gmail.com
Top comments (0)