Sunday, March 26, 2017

How to Install Laravel framework on Windows with XAMPP (as PHP development environment)

In this post, I will explain how to install Laravel framework on Windows, with XAMPP as PHP development environment.

First you have to install XAMPP you can find here: XAMPP Installer

You can install Laravel framework by using Composer. You can download composer from https://getcomposer.org/download/. Composer setup will ask for PHP installation path, in my XAMPP installation it is:

D:\xampp\php\php.exe

You can verify if composer is correctly installed, by executing the command composer in command prompt. If you get an error message, it means it is not added in the Environment Variables, so you have to add the composer.exe folder path in Environment Variables.

In-case if you have already have installed composer, its better to update it-self to the latest version before moving forward. Run the following command to update composer it-self.

composer self-update

Here we finished installing composer, and now we have to install Laravel. Move to a web-accessible folder, the folder where we usually place all web projects. In my XAMPP installation it is D:\xampp\htdocs

Now go to command prompt, move to the above mentioned web-accessible folder, and execute following command:

composer create-project --prefer-dist laravel/laravel myweb

It will install Laravel framework to a folder named myweb inside the htdocs folder, you can use your own project name in place of myweb (last part in the above command). Then composer will download and configure all the required dependencies, and finally your Laravel basic application is now ready.

If you have PHP installed locally with XAMPP and you may use PHP's built-in development server to serve your application. To make our development envrionment to server this website we have to use the artisan command. This command will start a development server.

You can try access it by localhost path:

http://localhost:8000

You should see the following home page for Laravel in your browser.

And it's done. We have successfully installed Laravel framework on our machine.

References

https://laravel.com/docs