Local Web Development

Typically you will develop a project in your local web server environment. There are two basic steps necessary:

  1. Creating a local domain for the project.
  2. Creating a VirtualHost for the project.

Some project might not technically require its own local domain, but we recommend to use a local domain for each project regardless.

The terms VirtualHost and DocumentRoot are specific to the Apache web server - however, it is used interchangeably for NGINX’ equivalent as well.

Create a local domain

Simply edit your /etc/hosts file (C:\Windows\System32\drivers\etc\hosts under Windows) and add a line like this:

127.0.0.1 example-project.local

This will instruct your operating system to redirect any request to the example-project.local domain to the local host (127.0.0.1), so that your local web server will handle the request.

Create a VirtualHost

After creating the local domain, use it for your VirtualHost of the project. The location of the appropriate Apache config file may vary - under Windows, when using the default XAMPP installation, it would be under C:\xampp\apache\conf\extra\httpd-vhosts.conf.

The bare minimum VirtualHost configuration would look like this:

<VirtualHost *:80>
    ServerName example-project.local
    DocumentRoot "C:/xampp/htdocs/example-project/web"
</VirtualHost>

In this example, the project is located within C:/xampp/htdocs/example-project and it is a Contao project, where you need to point the DocumentRoot to the /web subfolder of the installation.

After this, you need to start or re-start your web server and the project should be accessible under http://example-project.local/ in your browser.