Xampp is an open-source and completely free PHP development environment that includes Apache server, MariaDB database, as well as interpreters for PHP and Perl.
It is intended to be used only as a development tool because it allows the developers to easily develop and test their web applications on their local machines.
Grab an installer from the official Xampp website.
As you will see, Xampp is available for Windows, Linux, and Mac OS as well. After it downloads go ahead and start the installation process.
This is Xampp folder structure. Every web application including Laravel should be placed within htdocs folder. It is a good idea to create a folder for each website you create in order to prevent conflicts and strange behavior.
For Laravel, it is not necessary as we will specify folder name once we execute the project create command.
We will use a Composer to install a new Laravel application. Composer is a PHP package manager which allows us to install various PHP packages, including Laravel, update, and manage all the necessary dependencies.
You can download Composer from the official website. After it downloads go ahead and start the installation. If you are using an operating system other than Windows, you can find installation instructions on the website.
After the installation is complete we can check that it works by calling the composer from the command line terminal.
Press the windows home button and an R key on the keyboard. After CMD is opened type in composer and hit enter.
If you can see the following message in your terminal then Composer is installed successfully.
Finally, we can install Laravel by using a Composer command. Now, don’t forget, we have to be in the htdocs folder. From the current terminal position you can copy or type in the following in order to go to htdocs: “cd ../../xampp/htdocs”.
Once inside the folder, we can run:
composer create-project --prefer-dist laravel/laravel myproject.
Depending on your hardware and internet speed installation process should not take more than a couple of minutes. You can grab a glass of water or a snack until it finishes.
Serving the application
We now have two options for serving our freshly installed Laravel application. We can either call an artisan command inside our folder. php artisan serve which will serve the application on http://localhost:8000 local address.
The second option is to serve it with xampp and for that, we will have to create a virtual host within xampp configuration.
This is where you need to go: C:\xampp\apache\conf\extra\httpd-vhosts.conf
# VirtualHost for LARAVEL.DEV <VirtualHost myproject.test:80> DocumentRoot "C:\xampp\htdocs\myproject\public" <Directory "C:\xampp\htdocs\lmyproject"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>
We have told apache to listen to the connection on myproject.test. Next, we have to modify our hosts file which will redirect myproject.test to the localhost.
Hosts file is located here: C:\Windows\System32\drivers\etc
Add the following line: 127.0.0.1 myproject.test
Now you can start an apache service.