In this tutorial we will install Laravel in our local machine using composer and Xampp. Before that lets know about Laravel Composer and Xampp in short. If you know about them then just jump to the installation section.
What is Laravel ?
Laravel is a web application framework with expressive, elegant syntax. A web framework provides a structure and starting point for creating your application, allowing you to focus on creating something amazing while we sweat the details. (from Laravels Docs)
You can use Laravel as full-stack framework or backend only. It is an open source framework with great community support. At this point it is most popular PHP framework. So lets create something awesome with Laravel.
What Is Composer ?
Composer is dependency manager a tool for PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for your project . It helps us installing/updating various requirements/components for our app such as Laravel framework, Doctrine, Lodash and some other too.
What is Xammp
XAMPP is an abbreviation for cross-platform, Apache, MySQL, PHP and Perl, and it allows you to build Web applications offline, on a local web server on your computer. This simple and lightweight solution works on Windows, Linux, and Mac – hence the “cross-platform” part. Its main job is to serve the project and also manage the local database connection.
Here I will discuss how you can set-up Laravel development environment and run Laravel in your local machine in best way.
Step 1 : Install Composer
to install composer in windows 10 or any other windows machine visit Composer.org/download or click this for windows machine install by opening the downloaded file and set the PATH environment variable so you can simply call
composer from any directory That is the PHP directory (I assumed You have installed PHP in your machine to check just open terminal and type php -v it will print php version installed on your system if not you need to install php first.
now open terminal in any directory and type
composer -v and hit enter. if yo see something like below image the congratulations you have installed composer successfully.
Step 2 : Install Xampp
To download Xampp in your machine visit https://www.apachefriends.org/download.html and choose installer file compatible with your operating system and install it.
Stem 3 : Create New Laravel Project
If you have installed both composer and Xampp properly the you are ready to create fresh new Laravel project.
Navigate you directory where you want to create the project and open terminal in that directory or you can cd to that directory and run this command
composer create-project laravel/laravel ProjectName` replace "ProjectName"
with name of your project and it will starts to download all the necessary files on that directory.
Now you have installed A fresh new Laravel project now move to the project directory with command
and then run
php artisan serve
and open Xampp and start Apache and MYSQL service and after the server started visit https://127.168.0.1:8000 you will see Laravel's welcome page.
In Addition you can also install Laravel installer globally using composer using the command
composer global require laravel/installer
and after that you can use short command
laravel new ProjectName
from anywhere in your system.
hope you get something useful. If you have any questions, let me know in the comment. Thanks.