DEV Community

Dendi Handian
Dendi Handian

Posted on • Updated on

Adding an Existing Project to Laragon

Laragon is the super light-weight local server solution for your PHP application development. Even though I already recommend you to use Docker-based solution using Laradock, but Laragon still the lightest and simplest solution for you.

My first impression about Laragon at the first use is its lack of documentation for adding an existing project to the ecosystem, and I think they only provide feature to create a new one. I started to like Laragon until I figured out to add an existing project by myself. And I will show you how.

Prerequisites

Install the Laragon first by downloading the installer at the official download page or the github release page.
Then install it like any free software you had install (you knew it). You can start the laragon server right away and to make sure it works you can open http://localhost/ at your browser and you should see Laragon getting started page. And then prepare any laravel application somewhere in your machine drive to test the server host later.

Adding an existing laravel project to Laragon

If you are using Windows machine, the default Laragon folder should be in C:\laragon and you should find the C:\laragon\etc\apache2\sites-enabled\00-default file located here. Open the file using any text editor and you should see the default vhost config for laragon main page like this:

<VirtualHost _default_:80>
    <Directory "C:/laragon/www/">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Don't change anything to the above code, but we will insert the new config for our existing app in the new line. So, let's say I have a laravel project located in C:\Users\dendi\codes\simple-laravel-app. The configuration for the above project will be like this:

<VirtualHost *:80> 
    DocumentRoot "C:\Users\dendi\codes\simple-laravel-app\public"
    ServerName simple-laravel-app.test
    ServerAlias *.simple-laravel-app.test
    <Directory "C:\Users\dendi\codes\simple-laravel-app\public">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

The above way is the quickest for you to get started to add an existing project. However, I recommend you to put the vhost config on another file, let's say to all-my-projects.conf in the same folder beside the 00-default.conf file. It will prevent your vhost configuration to be gone if you accidentally change the apache2 version which will causing your 00-default.conf file to be reset.

Then reload your laragon server and add the host to C:\Windows\System32\drivers\etc\hosts file:

127.0.0.1 simple-laravel-app.test
Enter fullscreen mode Exit fullscreen mode

Then you should see your project is up at http://simple-laravel-app.test.

Have fun exploring laragon.

Discussion (2)

Collapse
ferial71 profile image
ferial71

thank you so much that was very helpful

Collapse
dendihandian profile image
Dendi Handian Author • Edited

Glad to hear that