# Configuring the web server

The web server should send all HTTP requests to the entry script (front controller) public/index.php.

To test the functionality or demonstrate the application, you can use the built-in PHP server. To do this, run the following command from the application root.

composer run serve

For any other tasks, use a full-featured web server.

PHP-FPM and Nginx must be installed. Do not forget to replace the values of the directives root, access_log, error_log with the correct paths, and server_name with your hostname.

server {
    charset utf-8;
    listen 80; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6

    server_name example.com;
    root        /path/to/public;
    index       index.php;

    access_log  /path/to/example.access.log;
    error_log   /path/to/example.error.log;

    location / {
        # Redirect all requests to non-existent directories and files to index.php
        try_files $uri $uri/ /index.php$is_args$args;
        # Trim the trailing slash
        rewrite ^/(.*)/$ /$1 permanent;

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        # Use a UNIX socket
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        # Use a TCP socket

    location ~ /\. {
        deny all;

For Apache, add the following code to the virtual host configuration file and replace path/to/public with the correct path to public.

# Set document root to be "public"
DocumentRoot "path/to/public"

<Directory "path/to/public">
    # Enable "mod_rewrite" module for URL support
    RewriteEngine on

    # If a directory or a file exists, use the request directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # If not, redirect the request to index.php
    RewriteRule . index.php

    # ... other settings ...